Last Updated: February 25, 2016
·
377
· jamesacklin

Show current Git branch in bash prompt

Add to your .bash_rc:

function parse_git_branch {
    git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1) /'
}
export PS1='\[\e[0;35m\]⌘\[\e[0m\] \[\e[0;36m\]\w/\[\e[0m\] \[\e[0;33m\]$(parse_git_branch)\[\e[0m\]'