Last active
December 23, 2015 09:59
-
-
Save jeffcarp/6618224 to your computer and use it in GitHub Desktop.
Color your git branch green or red based on whether you have uncommitted changes. (Put it in your ~/.bash_profile)
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
XRED="\033[0;31m" | |
XGREEN="\033[0;32m" | |
XNO_COLOUR="\033[0m" | |
function parse_git_branch () { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
} | |
branch_colorize () { | |
if [ -d .git ] | |
then | |
if ! git diff-files --quiet --ignore-submodules -- | |
then | |
echo -e "$XRED$(parse_git_branch)$XNO_COLOUR" | |
else | |
echo -e "$XGREEN$(parse_git_branch)$XNO_COLOUR" | |
fi | |
fi | |
} | |
PS1="夢 \w\$(branch_colorize) \$ " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment