Wednesday, October 10, 2012

Display active git branch in bash prompt

For linux..

$ sudo nano ~/.bashrc

Add the following line to the bottom..

PS1="\u@\h:\w\$(git branch 2>/dev/null | grep -e '\* ' | sed 's/^..\(.*\)/{\1}/') \$ "

Save and quit. Restart terminal. cd into your git repo and you should see you're current branch.

Ref: http://gregk.me/2011/display-active-git-branch-in-bash-prompt/

No comments:

Post a Comment

Popular Posts