Advertisement
Guest User

Untitled

a guest
May 27th, 2015
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. function git_prompt_info() {
  2. local COLOR="%{$fg_bold[magenta]%}"
  3. local REF
  4. local STATUS
  5. local DIRTY
  6. local DIRTYM
  7. local DIRTYA
  8. local DIRTYD
  9.  
  10. REF=$(command git symbolic-ref HEAD --short 2> /dev/null)
  11. if [[ -z $REF ]]; then
  12. REF=$(command git rev-parse --short HEAD 2> /dev/null) || return 0
  13. fi
  14. STATUS=$(command git status --porcelain)
  15. if [[ -n $STATUS ]]; then
  16. DIRTY="*"
  17. DIRTYM=$(command echo "$STATUS" | grep "^ M" | wc -l 2> /dev/null)
  18. if [[ $DIRTYM -gt 0 ]]; then
  19. DIRTY="$DIRTY %{$fg_bold[blue]%}±$DIRTYM$COLOR"
  20. fi
  21. DIRTYA=$(command echo "$STATUS" | grep "^??" | wc -l 2> /dev/null)
  22. if [[ $DIRTYA -gt 0 ]]; then
  23. DIRTY="$DIRTY %{$fg_bold[green]%}+$DIRTYA$COLOR"
  24. fi
  25. DIRTYD=$(command echo "$STATUS" | grep "^ D" | wc -l 2> /dev/null)
  26. if [[ $DIRTYD -gt 0 ]]; then
  27. DIRTY="$DIRTY %{$fg_bold[red]%}-$DIRTYD$COLOR"
  28. fi
  29. fi
  30. echo "$COLOR‹${REF}${DIRTY}›%{$reset_color%}"
  31. }
  32.  
  33. local return_code="%(?..%{$bg[red]%}%{$fg_bold[white]%} ret → %?
  34. %{$reset_color%})"
  35. local prefix_top='%{$fg[cyan]%}╭─%{$reset_color%}'
  36. local prefix_bottom='%{$fg[cyan]%}╰─%{$reset_color%}'
  37. local user_host='%{$fg[cyan]%}%n@%m%{$reset_color%}'
  38. local current_dir='%{$fg_bold[blue]%}%~%{$reset_color%}'
  39. local git_branch='$(git_prompt_info)'
  40.  
  41. PROMPT="${return_code}${prefix_top} ${user_host} ${current_dir} ${git_branch}
  42. ${prefix_bottom} "
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement