Skip to content

Instantly share code, notes, and snippets.

@galfert
Created June 13, 2009 09:13
Show Gist options
  • Save galfert/129157 to your computer and use it in GitHub Desktop.
Save galfert/129157 to your computer and use it in GitHub Desktop.
Show the git branch in bash prompt
function parse_git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo "("${ref#refs/heads/}")"
}
GREEN="\[\033[01;32m\]"
WHITE="\[\033[00m\]"
BLUE="\[\033[01;34m\]"
YELLOW="\[\033[0;33m\]"
PS1="$GREEN\u@\h$WHITE:$BLUE\w $YELLOW\$(parse_git_branch)$WHITE\$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment