
Bash git prompt
By: a guest on
Jul 22nd, 2012 | syntax:
Bash | size: 1.27 KB | hits: 24 | expires: Never
case "${TERM}" in
xterm*|rxvt*)
clr_mode=9
;;
*)
clr_mode=3
;;
esac
if [ ${UID} -eq 0 ] ; then
usr_color="\e[0;31m"
usr_sign="#"
else
usr_color="\e[0;${clr_mode}2m"
usr_sign="\$"
fi
# To enable showing the dirty (unstaged/staged) state, add the following line to your .bashrc 'before' your PS1 setting:
export GIT_PS1_SHOWDIRTYSTATE=1
# To enable showing the stashed state, add the following line to your .bashrc before your PS1 setting:
export GIT_PS1_SHOWSTASHSTATE=1
# To enable showing the untracked state, add the following line to your .bashrc before your PS1 setting:
export GIT_PS1_SHOWUNTRACKEDFILES=1
# To enable showing the upstream state, add the following line to your .bashrc before your PS1 setting:
export GIT_PS1_SHOWUPSTREAM="auto verbose"
git_prompt='$(__git_ps1 " *%s")'
if [ "$color_prompt" = yes ]; then
# PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
PS1="\[${usr_color}\]\u\[\e[m\] \[\e[1;34m\]\w\[\e[m\]\[\e[1;35m\]${git_prompt}\[\e[m\] \[${usr_color}\]${usr_sign}\[\e[m\] "
else
# PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
PS1="\u \w ${usr_sign}"
fi
unset color_prompt force_color_prompt usr_color usr_sign clr_mode git_prompt