I don’t know about you, but I’ve often forgotten what git branch I have checked out in my current repository directory.
I looked around, and found that there are some really useful contributions in the git repository on github:
The ones I’m going to talk about today however are these:
Put those in ~/.bash/
$ mkdir ~/.bash $ cd ~/.bash $ wget https://raw2.github.com/git/git/master/contrib/completion/git-completion.bash -O ~/.bash/git-completion.sh $ chmod +x ~/.bash/git-completion.sh $ wget https://raw2.github.com/git/git/master/contrib/completion/git-prompt.sh -O ~/.bash/git-prompt.sh $ chmod +x ~/.bash/git-prompt.sh
Now you just need to tie it together with some additions to your login scripts. my bash_profile looks like this:
#bash profile: ~/.bash_profile source ~/.bashrc source ~/.bash/git-completion.sh source ~/.bash/git-prompt.sh source ~/.bash/cdpath.sh RED="\[\033[0;31m\]" YELLOW="\[\033[0;33m\]" GREEN="\[\033[0;32m\]" PS1="$RED\w$YELLOW\$(__git_ps1)$GREEN\$ "
This very easily shows me what branch I’m on in any particular directory:
$ cd ~/myrepo ~/myrepo (master)$
Hope this helps someone else!