Created
March 6, 2012 10:30
-
-
Save jbarrett/1985588 to your computer and use it in GitHub Desktop.
Git prompt snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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