slenderock
8/21/2016 - 7:08 AM

colorized git ps1

colorized git ps1

#enables git colorized output (http://stackoverflow.com/questions/10998792/how-to-color-the-git-console-in-ubuntu)
$ git config --global color.ui auto
#...
__git_color_ps1 ()
{
    if [ -n "$(__git_ps1)" ]; then
	local IS_CLEAN=`git status | grep -c "working directory clean"`;
	if [ $IS_CLEAN -eq 0 ]; then
	    echo -e "\e[1;31m"
	else
	    echo -e "\e[1;37m"
	fi
    fi
}



#PS1="\u@\h:\w\[\$(__git_color_ps1)\]\$(__git_ps1)\[\e[0m\]\$ "
PS1="${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\$(__git_color_ps1)\]\$(__git_ps1)\[\e[0m\]\$ "
#...