sunrise.zsh-theme 2.9 KB

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