dotfiles

Unnamed repository; edit this file 'description' to name the repository.
git clone git://edryd.org/dotfiles
Log | Files | Refs

commit 937b145d41275420955445ccd3d422aa5cb73ad8
parent f972687ee52c33ab8460b7c83025bfde43dbb64e
Author: Ed van Bruggen <edvb54@gmail.com>
Date:   Wed,  1 Oct 2014 19:16:31 -0700

Bash: Add funtion git_color()
- makes git branch name change color based on status of the repository

Diffstat:
bashrc | 22+++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/bashrc b/bashrc @@ -56,10 +56,30 @@ cmd_check() { fi; } +# change color of branch name +git_color() { + if [ -d .git ] || git rev-parse --git-dir > /dev/null 2>&1; then + local color="${Cyan}" + + # modified + git diff --no-ext-diff --quiet --exit-code || color="${Red}" + + # staged + if git rev-parse --quiet --verify HEAD >/dev/null; then + git diff-index --cached --quiet HEAD -- || color="${IRed}" + fi + + # stashed + git rev-parse --verify refs/stash >/dev/null 2>&1 && color="${Yellow}" + + echo "$color" + fi +} + PS1='\ ${Blue}\u\ $(cmd_check) \ -$(__git_ps1 "${Cyan}%s ")${White}\ +$(__git_ps1 "$(git_color)%s ")${White}\ \$${Color_Off} \ '