Oct 30 2010

Git branch on shell promt

sas

Shows the current git branch on the shell promt

to show the git branch on the command promt set the PS1 var in .bashrc or .profile like this:

PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\e[0m\]\[\e[31m\]$(git branch 2>/dev/null|fgrep '\''*'\''|sed '\''s/$/)/;s/^* / (/'\'')\[\e[0m\]$ '