2014-03-12

Git branch name in your prompt

When you want to get something similar like
idea:~/my/project/hybris/order-service (develop) 
as your Bash prompt on a Mac or perhaps some other Unix OSs — where "(develop)" could be your currently checked out Git branch — add this
PS1='\h:\[\e[0;31m\]\w\[\e[m\]`__git_ps1` ' 
or 
PS1='\h:\[\e[0;31m\]\w\[\e[m\] \e[1;31m\]$(__git_ps1 %s)\e[m ' 
to your ~/.bash_profile

Alternatively you could use
PS1='`__git_ps1` '
just to see the branch name.