Show the current Git branch on your Bash prompt

Updated . Posted . Visible to the public.

Append this to your ~/.bashrc:

export PS1='\[\033[01;32m\]\h\[\033[01;34m\] \w\[\033[31m\]$(__git_ps1 "(%s)") \[\033[01;34m\]$\[\033[00m\] '

Reload the changes by saying

source ~/.bashrc

For some customized prompts that also show the current Git prompt, see the examples section at the bottom of our bash prompt customizing card.

Martin Straub
Last edit
Keywords
linux, shell
License
Source code in this card is licensed under the MIT License.
Posted by Martin Straub to makandra dev (2010-08-25 12:17)