.

Display git branch name at the prompt

2011-07-29 02:26:40

From here, where it will probably display neater as well.

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

PS1='${debian_chroot:+($debian_chroot)}\u@\h:\[\033[01;34m\]\w\[\033[00m\]\[\033[0;32m\]$(parse_git_branch_and_add_brackets)\[\033[00m\]\$ '