Display Git branch in Bash prompt

Published on Author admin

To display Git branch in Bash prompt append ~/.bashrc file with following content:

parse_git_branch() {
     git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}

export PS1="\[\e[92m\]\u@\h \[\e[94m\]\w \[\e[95m\]\$(parse_git_branch)\[\e[00m\]$ "