Skip to content

Instantly share code, notes, and snippets.

@binarycleric
Created September 25, 2012 15:11
Show Gist options
  • Save binarycleric/3782510 to your computer and use it in GitHub Desktop.
Save binarycleric/3782510 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/}") "
}
white='\[\e[37;1m\]'
green='\[\e[32;1m\]'
blue='\[\e[34;1m\]'
red='\[\e[31;1m\]'
nocolour='\[\e[0m\]'
user="\u"
export PS1="$green$user$white@$blue\h $red\W $white\$(parse_git_branch)\$$nocolour "
@zackdouglas
Copy link

What about git branch | grep '*' | cut -d ' ' -f 2 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment