From c51ac21a135b90fd45c8faea3c672228e5dcaf3a Mon Sep 17 00:00:00 2001 From: Scott Wallace Date: Mon, 9 Feb 2015 14:18:12 +0000 Subject: [PATCH] Print the current Git branch as part of the CLI prompt. --- .bashrc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.bashrc b/.bashrc index 104e654..4cf8f8c 100644 --- a/.bashrc +++ b/.bashrc @@ -19,7 +19,10 @@ export PATH=/usr/local/bin:/usr/local/sbin:${PATH} #-------------------------------------------------------------------------------- # A useful prompt #-------------------------------------------------------------------------------- -export PS1="[\u@\h \W]\\$ " +parse_git_branch() { + git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' +} +export PS1="[\u@\h \W \$(parse_git_branch)]\\$ " export PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"' #--------------------------------------------------------------------------------