Mar 11, 2013

Showing the current Git branch in a shell prompt

The following commands in ~/.bash_profile will show you on what Git branch you are and if there are dirty files there:

source /opt/local/share/doc/git-core/contrib/completion/git-completion.bash
source /opt/local/share/git-core/
export PS1='\h:\w \[\033[1;36m\]$(__git_ps1 "[%s] ")\[\033[1;37m\]\$ '

This will show the branch in the cyan color and only in the directory, where you checked out the project. If there are dirty files, it will show an asterisk after the branch name.


Atlas:~/Projects/TYPO3/TYPO3_6-0 [issue_46000 *] $

1 comment:

  1. I recommend you to take a look at zsh in combination with

    It supports the same feature, plus a lot of more nice stuff. All in all, it's much superior to bash & co., plus it also looks a lot better...