Don't like ads? PRO users don't see any ads ;-)
Guest

Bash git prompt

By: a guest on Jul 22nd, 2012  |  syntax: Bash  |  size: 1.27 KB  |  hits: 24  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. case "${TERM}" in
  2. xterm*|rxvt*)
  3.     clr_mode=9
  4.     ;;
  5. *)
  6.     clr_mode=3
  7.     ;;
  8. esac
  9.  
  10. if [ ${UID} -eq 0 ] ; then
  11.   usr_color="\e[0;31m"
  12.   usr_sign="#"
  13. else
  14.   usr_color="\e[0;${clr_mode}2m"
  15.   usr_sign="\$"
  16. fi
  17.  
  18. # To enable showing the dirty (unstaged/staged) state, add the following line to your .bashrc 'before' your PS1 setting:
  19. export GIT_PS1_SHOWDIRTYSTATE=1
  20. # To enable showing the stashed state, add the following line to your .bashrc before your PS1 setting:
  21. export GIT_PS1_SHOWSTASHSTATE=1
  22. # To enable showing the untracked state, add the following line to your .bashrc before your PS1 setting:
  23. export GIT_PS1_SHOWUNTRACKEDFILES=1
  24. # To enable showing the upstream state, add the following line to your .bashrc before your PS1 setting:
  25. export GIT_PS1_SHOWUPSTREAM="auto verbose"
  26. git_prompt='$(__git_ps1 " *%s")'
  27.  
  28. if [ "$color_prompt" = yes ]; then
  29. #     PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
  30.   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\] "
  31. else
  32. #     PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
  33.   PS1="\u \w ${usr_sign}"
  34. fi
  35. unset color_prompt force_color_prompt usr_color usr_sign clr_mode git_prompt