Created
January 24, 2014 19:27
-
-
Save cie/8604271 to your computer and use it in GitHub Desktop.
A colored indicator of the git tree status
This file contains hidden or 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
git_ps1() { | |
GIT_PS1="$(__git_ps1)" | |
if [ "$GIT_PS1" ]; then | |
GIT_STATUS=$(git status --porcelain) | |
# if there are modified files | |
if echo "$GIT_PS1" | grep 'CONFLICT' > /dev/null; then | |
GIT_COLOR=31 | |
elif echo "$GIT_STATUS" | grep '^.M' > /dev/null ; then | |
GIT_COLOR=35 | |
# if there are unknown files | |
elif echo "$GIT_STATUS" | grep '^??' > /dev/null ; then | |
GIT_COLOR=33 | |
# if there are staged changes | |
elif echo "$GIT_STATUS" | grep '^[^ ]' > /dev/null ; then | |
GIT_COLOR=36 | |
else | |
GIT_COLOR=32 | |
fi | |
echo -ne '\033[01;'$GIT_COLOR'm'"$GIT_PS1" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment