Show the current Git branch on your Bash prompt

Posted Over 13 years ago. 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.

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