Skip to content

Instantly share code, notes, and snippets.

@Valarissa
Forked from binarycleric/gist:3782510
Created September 25, 2012 15:12
Show Gist options
  • Save Valarissa/3782511 to your computer and use it in GitHub Desktop.
Save Valarissa/3782511 to your computer and use it in GitHub Desktop.
Git branch in prompt
function parse_git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo "("${ref#refs/heads/}") "
}
green='\[\e[32;1m\]'
blue='\[\e[34;1m\]'
red='\[\e[31;1m\]'
nocolour='\[\e[0m\]'
user="\u"
export PS1="$green$user $red\W $blue\$(parse_git_branch)$nocolour\$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment