Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. #git branch
  2. # __git_branch='`git branch 2> /dev/null | grep -e ^* | sed -E s/^\\\\\*\ \(.+\)$/\(\\\\\1\)\ /`'
  3. # "\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ "
  4.  
  5. function parse_git_dirty {
  6. echo -n $(git status 2>/dev/null | awk -v out=$1 -v std="dirty" '{ if ($0=="# Changes to be committed:") std = "uncommited"; last=$0 } END{ if(last!="" && last!="nothing to commit (working directory clean)") { if(out!="") print out; else print std } }')
  7. }
  8. function parse_git_branch {
  9. echo -n $(git branch --no-color 2>/dev/null | awk -v out=$1 '/^*/ { if(out=="") print $2; else print out}')
  10. }
  11. function parse_git_remote {
  12. echo -n $(git status 2>/dev/null | awk -v out=$1 '/# Your branch is / { if(out=="") print $5; else print out }')
  13. }
  14. if [ -d .git ]
  15. then
  16. read hd <.git/HEAD
  17. [[ $hd < g ]] && hd="${hd::7}" || hd="${hd##*/}"
  18. fi
  19.  
  20. # export PS1="\`if [ \$? = 0 ]; then echo \[\e[33m\]^_^\[\e[0m\]; else echo \[\e[31m\]O_O\[\e[0m\]; fi\` \[\033[36m\]\u\[\033[m\]\[\e[1;31m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\[\033[37;1m\]\$\[\033[m\] "
  21.  
  22. # export PS1="\`if [ \$? = 0 ]; then echo \[\e[33m\]^_^\[\e[0m\]; else echo \[\e[31m\]O_O\[\e[0m\]; fi\` \[\033[36m\]\u\[\033[m\]\[\e[1;31m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\[\033[37;1m\]\$\[\033[m\] \e[36m $parse_git_branch \[\e[m\]"
  23.  
  24.  
  25. # .bashrc loaded by .profile
  26. # [[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
  27.  
  28. [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
  29.  
  30. function myBashPrompt {
  31. local __userandhost="\`if [ \$? = 0 ]; then echo \[\e[33m\]^_^\[\e[0m\]; else echo \[\e[31m\]O_O\[\e[0m\]; fi\` \[\033[36m\]\u\[\033[m\]\[\e[1;31m\]@\[\033[32m\]\h:"
  32. local __pwd="\[\033[33;1m\]\w"
  33. local __gitbranch_color="\[\033[31m\]"
  34. local __gitbranch='`git branch 2> /dev/null | grep -e ^* | sed -E s/^\\\\\*\ \(.+\)$/\(\\\\\1\)\ /`'
  35. local __prompt_tail="\[\033[34m\]$"
  36. local __shellcolor="\[\033[00m\]"
  37. export PS1="$__userandhost$__pwd $__gitbranch_color$__gitbranch$__prompt_tail$__shellcolor "
  38. }
  39. myBashPrompt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement