This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# snip .bashrc | |
function bash_git_branch | |
{ | |
git branch 2> /dev/null | grep \* | python -c "print '['+raw_input()[2:]+']'" 2> /dev/null | |
} | |
#snip .bashrc | |
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(bash_git_branch)\$ ' | |
#snip the rest |
This will show up a prompt which looks like this and fails gracefully when you are not on a git repo.
vagmi@deepthought:~/work/testproj[master]$ git checkout new_feature
Switched to branch "new_feature"
vagmi@deepthought:~/work/testproj[new_feature]$ cd ..
vagmi@deepthought:~/work$
This saves a lot of "git branch" when you are coding.