steeef.zsh-theme 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. # vim:et sts=2 sw=2 ft=zsh
  2. #
  3. # A customizable version of the steeef theme from
  4. # https://github.com/robbyrussell/oh-my-zsh/blob/master/themes/steeef.zsh-theme
  5. #
  6. # Requires the `git-info` zmodule to be included in the .zimrc file.
  7. prompt_steeef_help () {
  8. cat <<EOH
  9. This prompt can be customized with:
  10. prompt steeef [username_color] [hostname_color] [pwd_color] [branch_color]
  11. [unindexed_color] [unindexed_indicator]
  12. [indexed_color] [indexed_indicator]
  13. [untracked_color] [untracked_indicator]
  14. [stashed_color] [stashed_indicator]
  15. The default values for each parameter, for 256-color terminals (or otherwise)
  16. are the following:
  17. 1. username color: 135 (or magenta)
  18. 2. hostname color: 166 (or yellow)
  19. 3. current working directory color: 118 (or green)
  20. 4. git branch name color: 81 (or cyan)
  21. 5. git unindexed color: 166 (or yellow)
  22. 6. git unindexed indicator: ●
  23. 7. git indexed color: 118 (or green)
  24. 8. git indexed indicator: ●
  25. 9. git untracked color: 161 (or red)
  26. 10. git untracked indicator: ●
  27. The git stashed color and indicator are not defined by default, and will not be
  28. shown unless defined.
  29. EOH
  30. }
  31. prompt_steeef_git() {
  32. [[ -n ${git_info} ]] && print -n " ${(e)git_info[prompt]}"
  33. }
  34. prompt_steeef_virtualenv() {
  35. [[ -n ${VIRTUAL_ENV} ]] && print -n " (%F{blue}${VIRTUAL_ENV:t}%f)"
  36. }
  37. prompt_steeef_precmd() {
  38. (( ${+functions[git-info]} )) && git-info
  39. }
  40. prompt_steeef_setup() {
  41. [[ -n ${VIRTUAL_ENV} ]] && export VIRTUAL_ENV_DISABLE_PROMPT=1
  42. local col_user
  43. local col_host
  44. local col_pwd
  45. local col_brnch
  46. local col_unidx
  47. local col_idx
  48. local col_untrk
  49. # use extended color palette if available
  50. if (( terminfo[colors] >= 256 )); then
  51. col_user="%F{${1:-135}}"
  52. col_host="%F{${2:-166}}"
  53. col_pwd="%F{${3:-118}}"
  54. col_brnch="%F{${4:-81}}"
  55. col_unidx="%F{${5:-166}}"
  56. col_idx="%F{${7:-118}}"
  57. col_untrk="%F{${9:-161}}"
  58. else
  59. col_user="%F{${1:-magenta}}"
  60. col_host="%F{${2:-yellow}}"
  61. col_pwd="%F{${3:-green}}"
  62. col_brnch="%F{${4:-cyan}}"
  63. col_unidx="%F{${5:-yellow}}"
  64. col_idx="%F{${7:-green}}"
  65. col_untrk="%F{${9:-red}}"
  66. fi
  67. local ind_unidx=${6:-●}
  68. local ind_idx=${8:-●}
  69. local ind_untrk=${10:-●}
  70. local col_stash=${11:+%F{${11}}}
  71. local ind_stash=${12}
  72. autoload -Uz add-zsh-hook && add-zsh-hook precmd prompt_steeef_precmd
  73. prompt_opts=(cr percent sp subst)
  74. zstyle ':zim:git-info' verbose 'yes'
  75. zstyle ':zim:git-info:branch' format '%b'
  76. zstyle ':zim:git-info:commit' format '%c'
  77. zstyle ':zim:git-info:action' format "(${col_idx}%s%f)"
  78. zstyle ':zim:git-info:unindexed' format "${col_unidx}${ind_unidx}"
  79. zstyle ':zim:git-info:indexed' format "${col_idx}${ind_idx}"
  80. zstyle ':zim:git-info:untracked' format "${col_untrk}${ind_untrk}"
  81. if [[ -n ${ind_stash} ]]; then
  82. zstyle ':zim:git-info:stashed' format "${col_stash}${ind_stash}"
  83. fi
  84. zstyle ':zim:git-info:keys' format \
  85. 'prompt' "(${col_brnch}%b%c%I%i%u%f%S%f)%s"
  86. PS1="
  87. ${col_user}%n%f at ${col_host}%m%f in ${col_pwd}%~%f\$(prompt_steeef_git)\$(prompt_steeef_virtualenv)
  88. %(!.#.$) "
  89. RPS1=''
  90. }
  91. prompt_steeef_preview () {
  92. if (( ${#} )); then
  93. prompt_preview_theme steeef "${@}"
  94. else
  95. prompt_preview_theme steeef
  96. print
  97. prompt_preview_theme steeef magenta yellow green cyan magenta '!' green '+' red '?' yellow '$'
  98. fi
  99. }
  100. prompt_steeef_setup "${@}"