Skip to content

Instantly share code, notes, and snippets.

@arnaudsj
Created May 5, 2009 15:20
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 arnaudsj/107006 to your computer and use it in GitHub Desktop.
Save arnaudsj/107006 to your computer and use it in GitHub Desktop.
# Bash ~/.profile extract to display current git branch
# For Example:
# toto@mylaptop.local ~/Development/MyProject
# 10:17:39 ^master $
function parse_git_branch
{
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo ${ref#refs/heads/}
}
declare -x PS1='\[\033[01;32m\]\u@\H \[\033[01;35m\]\w\n\[\033[00m\]\t \[\033[01;32m\]\[\033[01;30m\]^$(parse_git_branch)\[\033[01;32m\] \$\[\033[00m\] '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment