Skip to content

Instantly share code, notes, and snippets.

@jbarrett
Created March 6, 2012 10:30
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 jbarrett/1985588 to your computer and use it in GitHub Desktop.
Save jbarrett/1985588 to your computer and use it in GitHub Desktop.
Git prompt snippet
# from http://www.entropy.ch/blog/Developer/2009/03/30/Git-and-SVN-Status-in-the-Bash-Prompt.html :
# Prompt setup, with SCM status
parse_git_branch() {
local DIRTY STATUS
STATUS=$(git status 2>/dev/null)
[ $? -eq 128 -o $? -eq 127 ] && return
[[ "$STATUS" == *'working directory clean'* ]] || DIRTY=' *'
echo "($(git branch 2>/dev/null | sed -e '/^[^*]/d' -e 's/* //')$DIRTY)"
}
PS1='\[\e[1;32m\]\u\[\e[m\]@\[\e[1;36m\]\h\[\e[m\]:\[\e[1;34m\]\w\[\e[m\]\[\e[m\]$(parse_git_branch)\$ '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment