Skip to content

Instantly share code, notes, and snippets.

@romac
Created May 4, 2011 20:16
Show Gist options
  • Save romac/955941 to your computer and use it in GitHub Desktop.
Save romac/955941 to your computer and use it in GitHub Desktop.
Git branch in PS1
parse_git_branch()
{
if [[ -d ./.git ]]; then
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \[\1\]/'
fi
}
PS1='\[\033[01;37m\]\w\[\033[00;35m\]$(parse_git_branch)\[\033[00m\] \$ '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment