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.


No comments:

Post a Comment

Popular Posts