Created
December 8, 2015 14:55
-
-
Save cmwright/b5f9dc3830e9bf53f221 to your computer and use it in GitHub Desktop.
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
# this requires git-completion (`brew install git bash-completion`) | |
c_cyan=`tput setaf 6` | |
c_red=`tput setaf 1` | |
c_green=`tput setaf 2` | |
c_sgr0=`tput sgr0` | |
branch_color () | |
{ | |
if git rev-parse --git-dir >/dev/null 2>&1 | |
then | |
git_status="$(git status 2> /dev/null)" | |
color="" | |
if [[ ${git_status} =~ "working directory clean" ]]; then | |
color="${c_green}" | |
else | |
color=${c_red} | |
fi | |
else | |
return 0 | |
fi | |
echo -ne $color | |
} | |
export PS1='\w\[${c_sgr0}\]\[$(branch_color)\]$(__git_ps1)\[${c_sgr0}\]: ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment