Skip to content

Instantly share code, notes, and snippets.

@ritxi
Created January 20, 2012 14:37
Show Gist options
  • Save ritxi/1647628 to your computer and use it in GitHub Desktop.
Save ritxi/1647628 to your computer and use it in GitHub Desktop.
git color
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
color=""
if git diff --quiet 2>/dev/null >&2
then
color="${c_green}"
else
color=${c_red}
fi
else
return 0
fi
echo -ne $color
}
PS1='\[$(branch_color)\]$(__git_ps1)\[${c_sgr0}\] \u@\[${c_red}\]\w\[${c_sgr0}\]: '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment