Skip to content

Instantly share code, notes, and snippets.

@erubboli
Created December 4, 2011 11:27
Show Gist options
  • Save erubboli/1429946 to your computer and use it in GitHub Desktop.
Save erubboli/1429946 to your computer and use it in GitHub Desktop.
add branch to PS1
function parse_git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return;
echo "["${ref#refs/heads/}"]"
}
PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\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