Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Rodrigora
Created June 4, 2013 16:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rodrigora/ba732b137e77f9f0139f to your computer and use it in GitHub Desktop.
Save Rodrigora/ba732b137e77f9f0139f to your computer and use it in GitHub Desktop.
git branch on prompt
parse_git_branch() {
if ! git rev-parse --git-dir > /dev/null 2>&1; then
return 0
fi
git_branch=$(git branch 2>/dev/null| sed -n '/^\*/s/^\* //p')
echo "[$git_branch]"
}
PS1="${debian_chroot:+($debian_chroot)}\[\033[01;36m\]\u@\h\[\033[00m\]:\[\033[01;32m\]\w\[\033[00m\]\[\033[01;31m\]\$(parse_git_branch)\[\033[00m\]$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment