Last Updated: February 25, 2016
·
436
· urbansky

Git branch in your terminal prompt

Put this in your .bash_profile

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

export PS1="\[\033[00m\]\u@\h\[\033[01;34m\] \W \[\033[31m\]\$(parse_git_branch) \[\033[00m\]$\[\033[00m\] "

Example:

Picture

Taken from: http://betterexplained.com/articles/aha-moments-when-learning-git/