sunrise.zsh-theme 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #-------------------------------------------------------------------------------
  2. # Sunrise theme for oh-my-zsh by Adam Lindberg (eproxus@gmail.com)
  3. # Intended to be used with Solarized: http://ethanschoonover.com/solarized
  4. # (Needs Git plugin for current_branch method)
  5. #-------------------------------------------------------------------------------
  6. # Color shortcuts
  7. R=$fg[red]
  8. G=$fg[green]
  9. M=$fg[magenta]
  10. RB=$fg_bold[red]
  11. YB=$fg_bold[yellow]
  12. BB=$fg_bold[blue]
  13. RESET=$reset_color
  14. if [ "$(whoami)" = "root" ]; then
  15. PROMPTCOLOR="%{$RB%}" PREFIX="-!-";
  16. else
  17. PROMPTCOLOR="" PREFIX="---";
  18. fi
  19. local return_code="%(?..%{$R%}%? ↵%{$RESET%})"
  20. # Get the status of the working tree (copied and modified from git.zsh)
  21. custom_git_prompt_status() {
  22. INDEX=$(git status --porcelain 2> /dev/null)
  23. STATUS=""
  24. # Non-staged
  25. if $(echo "$INDEX" | grep '^?? ' &> /dev/null); then
  26. STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS"
  27. fi
  28. if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then
  29. STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS"
  30. fi
  31. if $(echo "$INDEX" | grep '^ D ' &> /dev/null); then
  32. STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS"
  33. fi
  34. if $(echo "$INDEX" | grep '^.M ' &> /dev/null); then
  35. STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
  36. elif $(echo "$INDEX" | grep '^AM ' &> /dev/null); then
  37. STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
  38. elif $(echo "$INDEX" | grep '^ T ' &> /dev/null); then
  39. STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
  40. fi
  41. # Staged
  42. if $(echo "$INDEX" | grep '^D ' &> /dev/null); then
  43. STATUS="$ZSH_THEME_GIT_PROMPT_STAGED_DELETED$STATUS"
  44. fi
  45. if $(echo "$INDEX" | grep '^R' &> /dev/null); then
  46. STATUS="$ZSH_THEME_GIT_PROMPT_STAGED_RENAMED$STATUS"
  47. fi
  48. if $(echo "$INDEX" | grep '^M ' &> /dev/null); then
  49. STATUS="$ZSH_THEME_GIT_PROMPT_STAGED_MODIFIED$STATUS"
  50. fi
  51. if $(echo "$INDEX" | grep '^A' &> /dev/null); then
  52. STATUS="$ZSH_THEME_GIT_PROMPT_STAGED_ADDED$STATUS"
  53. fi
  54. if $(echo -n "$STATUS" | grep '.*' &> /dev/null); then
  55. STATUS="$ZSH_THEME_GIT_STATUS_PREFIX$STATUS"
  56. fi
  57. echo $STATUS
  58. }
  59. # get the name of the branch we are on (copied and modified from git.zsh)
  60. function custom_git_prompt() {
  61. ref=$(git symbolic-ref HEAD 2> /dev/null) || return
  62. echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$(git_prompt_ahead)$(custom_git_prompt_status)$ZSH_THEME_GIT_PROMPT_SUFFIX"
  63. }
  64. # %B sets bold text
  65. PROMPT='%B$PREFIX %2~ $(custom_git_prompt)%{$M%}%B»%b%{$RESET%} '
  66. RPS1="${return_code}"
  67. ZSH_THEME_GIT_PROMPT_PREFIX="%{$YB%}‹"
  68. ZSH_THEME_GIT_PROMPT_SUFFIX="%{$YB%}›%{$RESET%} "
  69. ZSH_THEME_GIT_PROMPT_DIRTY="%{$R%}*"
  70. ZSH_THEME_GIT_PROMPT_CLEAN=""
  71. ZSH_THEME_GIT_PROMPT_AHEAD="%{$BB%}➔"
  72. ZSH_THEME_GIT_STATUS_PREFIX=" "
  73. # Staged
  74. ZSH_THEME_GIT_PROMPT_STAGED_ADDED="%{$G%}A"
  75. ZSH_THEME_GIT_PROMPT_STAGED_MODIFIED="%{$G%}M"
  76. ZSH_THEME_GIT_PROMPT_STAGED_RENAMED="%{$G%}R"
  77. ZSH_THEME_GIT_PROMPT_STAGED_DELETED="%{$G%}D"
  78. # Not-staged
  79. ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$R%}⁇"
  80. ZSH_THEME_GIT_PROMPT_MODIFIED="%{$R%}M"
  81. ZSH_THEME_GIT_PROMPT_DELETED="%{$R%}D"
  82. ZSH_THEME_GIT_PROMPT_UNMERGED="%{$R%}UU"