Guest User

Untitled

a guest
May 16th, 2012
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.96 KB | None | 0 0
  1. c_cyan=`tput setaf 6`
  2. c_blue=`tput setaf 4`
  3.     c_red=`tput setaf 1`
  4.     c_green=`tput setaf 2`
  5.     c_sgr0=`tput sgr0`
  6.  
  7.     parse_git_branch ()
  8.     {
  9.       if git rev-parse --git-dir >/dev/null 2>&1
  10.       then
  11.               gitver=$(git branch 2>/dev/null| sed -n '/^\*/s/^\* //p')
  12.       else
  13.               return 0
  14.       fi
  15.       echo -e " ($gitver)"
  16.     }
  17.  
  18.     branch_color ()
  19.     {
  20.             if git rev-parse --git-dir >/dev/null 2>&1
  21.             then
  22.                     color=""
  23.                     if git diff --quiet 2>/dev/null >&2
  24.                     then
  25.                             color="${c_green}"
  26.                     else
  27.                             color=${c_red}
  28.                     fi
  29.             else
  30.                     return 0
  31.             fi
  32.             echo -ne $color
  33.     }
  34.        
  35.         PS1='${debian_chroot:+($debian_chroot)}\[${c_green}\]\u@\h\[${c_sgr0}\]:\[${c_blue}\]\w\[$(branch_color)\]$(parse_git_branch)\[${c_sgr0}\]$ '
Advertisement
Add Comment
Please, Sign In to add comment