Last active
August 29, 2015 13:56
-
-
Save danhunter/9232657 to your computer and use it in GitHub Desktop.
.bash_profile
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
c_path=`tput setaf 6` | |
c_stgd=`tput setaf 2` | |
c_unstgd=`tput setaf 9` | |
c_sgr0=`tput sgr0` | |
parse_git_branch () | |
{ | |
if git rev-parse --git-dir >/dev/null 2>&1 | |
then | |
gitver=$(git branch 2>/dev/null| sed -n '/^\*/s/^\* //p') | |
else | |
return 0 | |
fi | |
echo -e $gitver | |
} | |
branch_color () | |
{ | |
if git rev-parse --git-dir >/dev/null 2>&1 | |
then | |
color="" | |
if git diff --quiet 2>/dev/null >&2 | |
then | |
color="${c_stgd}" | |
else | |
color="${c_unstgd}" | |
fi | |
else | |
return 0 | |
fi | |
echo -ne $color | |
} | |
export PS1='[\[$(branch_color)\]$(parse_git_branch)\[${c_sgr0}\]] \u@\[${c_path}\]\w\[${c_sgr0}\]: ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Color codes branch name based on the presence of uncommitted changes