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_no_bold[red]
  8. G=$fg_no_bold[green]
  9. M=$fg_no_bold[magenta]
  10. Y=$fg_no_bold[yellow]
  11. B=$fg_no_bold[blue]
  12. RESET=$reset_color
  13. if [ "$(whoami)" = "root" ]; then
  14. PROMPTCOLOR="%{$R%}" PREFIX="-!-";
  15. else
  16. PROMPTCOLOR="" PREFIX="---";
  17. fi
  18. local return_code="%(?..%{$R%}%? ↵%{$RESET%})"
  19. # Get the status of the working tree (copied and modified from git.zsh)
  20. custom_git_prompt_status() {
  21. INDEX=$(git status --porcelain 2> /dev/null)
  22. STATUS=""
  23. # Non-staged
  24. if $(echo "$INDEX" | grep '^?? ' &> /dev/null); then
  25. STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS"
  26. fi
  27. if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then
  28. STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS"
  29. fi
  30. if $(echo "$INDEX" | grep '^ D ' &> /dev/null); then
  31. STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS"
  32. fi
  33. if $(echo "$INDEX" | grep '^.M ' &> /dev/null); then
  34. STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
  35. elif $(echo "$INDEX" | grep '^AM ' &> /dev/null); then
  36. STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
  37. elif $(echo "$INDEX" | grep '^ T ' &> /dev/null); then
  38. STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
  39. fi
  40. # Staged
  41. if $(echo "$INDEX" | grep '^D ' &> /dev/null); then
  42. STATUS="$ZSH_THEME_GIT_PROMPT_STAGED_DELETED$STATUS"
  43. fi
  44. if $(echo "$INDEX" | grep '^R' &> /dev/null); then
  45. STATUS="$ZSH_THEME_GIT_PROMPT_STAGED_RENAMED$STATUS"
  46. fi
  47. if $(echo "$INDEX" | grep '^M' &> /dev/null); then
  48. STATUS="$ZSH_THEME_GIT_PROMPT_STAGED_MODIFIED$STATUS"
  49. fi
  50. if $(echo "$INDEX" | grep '^A' &> /dev/null); then
  51. STATUS="$ZSH_THEME_GIT_PROMPT_STAGED_ADDED$STATUS"
  52. fi
  53. if $(echo -n "$STATUS" | grep '.*' &> /dev/null); then
  54. STATUS="$ZSH_THEME_GIT_STATUS_PREFIX$STATUS"
  55. fi
  56. echo $STATUS
  57. }
  58. # get the name of the branch we are on (copied and modified from git.zsh)
  59. function custom_git_prompt() {
  60. ref=$(git symbolic-ref HEAD 2> /dev/null) || return
  61. echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$(git_prompt_ahead)$(custom_git_prompt_status)$ZSH_THEME_GIT_PROMPT_SUFFIX"
  62. }
  63. # %B sets bold text
  64. PROMPT='%B$PREFIX %2~ $(custom_git_prompt)%{$M%}%B»%b%{$RESET%} '
  65. RPS1="${return_code}"
  66. ZSH_THEME_GIT_PROMPT_PREFIX="%{$Y%}‹"
  67. ZSH_THEME_GIT_PROMPT_SUFFIX="%{$Y%}›%{$RESET%} "
  68. ZSH_THEME_GIT_PROMPT_DIRTY="%{$R%}*"
  69. ZSH_THEME_GIT_PROMPT_CLEAN=""
  70. ZSH_THEME_GIT_PROMPT_AHEAD="%{$B%}➔"
  71. ZSH_THEME_GIT_STATUS_PREFIX=" "
  72. # Staged
  73. ZSH_THEME_GIT_PROMPT_STAGED_ADDED="%{$G%}A"
  74. ZSH_THEME_GIT_PROMPT_STAGED_MODIFIED="%{$G%}M"
  75. ZSH_THEME_GIT_PROMPT_STAGED_RENAMED="%{$G%}R"
  76. ZSH_THEME_GIT_PROMPT_STAGED_DELETED="%{$G%}D"
  77. # Not-staged
  78. ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$R%}?"
  79. ZSH_THEME_GIT_PROMPT_MODIFIED="%{$R%}M"
  80. ZSH_THEME_GIT_PROMPT_DELETED="%{$R%}D"
  81. ZSH_THEME_GIT_PROMPT_UNMERGED="%{$R%}UU"