Skip to content

Instantly share code, notes, and snippets.

@JonTheWhite
Created January 16, 2012 14:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JonTheWhite/1621208 to your computer and use it in GitHub Desktop.
Save JonTheWhite/1621208 to your computer and use it in GitHub Desktop.
git branch in shell
# Add this to bashrc.
__git_ps1 ()
{
local b="$(git symbolic-ref HEAD 2>/dev/null)";
if [ -n "$b" ]; then
printf " (%s)" "${b##refs/heads/}";
fi
}
PS1="\${debian_chroot:+(\$debian_chroot)}\[\033[01;32m\]\u\[\033[01;34m\] \w\[\033[35m\]\$(__git_ps1) \[\033[01;34m\]\$\[\033[00m\] "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment