Skip to content

Instantly share code, notes, and snippets.

@pepl
Created October 3, 2013 08:25
Show Gist options
  • Save pepl/6806879 to your computer and use it in GitHub Desktop.
Save pepl/6806879 to your computer and use it in GitHub Desktop.
.bashrc git branch
parse_git_branch() {
git branch 2> /dev/null | perl -lanE 'if (/^\* (.*)/) { $b=$1; $b=~s/^(.{20}).+/$1.../; say "[$b]"; }'
}
export PS1='\[\e[32;1m\]\u@${debian_chroot:+($debian_chroot)}\h\[\e[0m\]:\[\e[36;1m\]\w\[\e[0m\]\[\e[31;1m\]$(parse_git_branch)\[\e[0m\]$ '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment