Show the current Git branch on your Bash prompt

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.

Over 13 years ago