emotty.zsh-theme 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #!/usr/bin/env zsh
  2. # ------------------------------------------------------------------------------
  3. # FILE: emotty.zsh-theme
  4. # DESCRIPTION: A varying emoji based theme
  5. # AUTHOR: Alexis Hildebrandt (afh[at]surryhill.net)
  6. # VERSION: 1.0.0
  7. # DEPENDS: emotty plugin
  8. # RECOMMENDS: Hasklig font
  9. #
  10. # This theme shows a different emoji for each tty at the main prompt.
  11. #
  12. # There are pre-defined different emoji sets to choose from, e.g.:
  13. # emoji, stellar, floral, zodiac, love (see emotty plugin).
  14. #
  15. # To choose a different emotty set than the default (emoji)
  16. # % export emotty_set=nature
  17. #
  18. # For the superuser (root) this theme shows a designated indicator
  19. # and switches the foreground color to red
  20. # (see root_prompt variable, default: skull).
  21. # But you are using sudo (8) instead of designated a root shell, right‽
  22. #
  23. # When logged in via SSH the main prompt also shows the user- and hostname.
  24. #
  25. # The exit status of the last failed command is displayed in the window title
  26. # along with an indicator (see warn_glyph variable, default: collision symbol).
  27. # To clear it just run: $NULL, true or :
  28. #
  29. # The right prompt shows the current working directory (3 levels up) in cyan.
  30. #
  31. # When in a git repository the main prompt shows the current branch name
  32. # with a branch indicator in yellow
  33. # (see vcs_branch_glyph variable, default: Hasklig branch glyph).
  34. #
  35. # If there are modified files the prompt switches to red and shows an unstaged
  36. # indicator (see vcs_unstaged_glyph variable, default: circled letter M).
  37. #
  38. # If there are staged files the prompt switches to green and shows an staged
  39. # indicator (see vcs_staged_glyph variable, default: high voltage sign).
  40. #
  41. # In a git repository the right prompt shows the repository name in bold and
  42. # prepends the current working directory subpath within the repository.
  43. #
  44. # When git currently performs an action such as merge or rebase, the action is
  45. # displayed in red instead of the branch name and a special action indicator
  46. # is shown (see vcs_action_glyph variable, default: chevron).
  47. # ------------------------------------------------------------------------------
  48. user_prompt="$(emotty)"
  49. root_prompt="$emoji[skull]"
  50. warn_prompt="$emoji[collision_symbol]"
  51. vcs_unstaged_glyph="%{$emoji[circled_latin_capital_letter_m]$emoji2[emoji_style] %2G%}"
  52. vcs_staged_glyph="%{$emoji[high_voltage_sign] %2G%}"
  53. vcs_branch_glyph=$(print -P $'\Ue0a0') # 
  54. vcs_action_glyph=$(print -P $'\U276f') # ❯
  55. red="$FG[001]"
  56. yellow="$FG[003]"
  57. green="$FG[002]"
  58. cyan="$FG[014]"
  59. prompt_glyph="%{%(#.${root_prompt}.${user_prompt}) %2G%}"
  60. # Uncomment the next line if you also like to see the warn_prompt in the prompt on the right.
  61. #last_command_failed="%(?.. %F{red}%1{${warn_prompt} %1G%}%?%f)"
  62. setopt promptsubst
  63. autoload -U add-zsh-hook
  64. autoload -Uz vcs_info
  65. zstyle ':vcs_info:*' enable git #hg svn cvs
  66. zstyle ':vcs_info:*' get-revision false
  67. zstyle ':vcs_info:*' check-for-changes true
  68. zstyle ':vcs_info:git:*' unstagedstr "${red}${vcs_unstaged_glyph}"
  69. zstyle ':vcs_info:*' stagedstr "${green}${vcs_staged_glyph}"
  70. # %(K|F){color} set (back|fore)ground color
  71. # %(k|f) reset (back|fore)ground color
  72. zstyle ':vcs_info:*' max-exports 3
  73. zstyle ':vcs_info:*' nvcsformats "${prompt_glyph}" '%3~' ''
  74. zstyle ':vcs_info:*' formats "${yellow}%u%c%b${vcs_branch_glyph}%f" '%S|' "$FX[bold]%r$FX[no-bold]"
  75. zstyle ':vcs_info:*' actionformats "${red}%K{white}%a${vcs_action_glyph}%k%f" '%S|' "$FX[bold]%r$FX[no-bold]"
  76. red_if_root="%(!.%F{red}.)"
  77. sshuser_on_host="${SSH_TTY:+%(!.$red.$yellow)%n@%m$reset_color}"
  78. PROMPT='${sshuser_on_host}${vcs_info_msg_0_}${red_if_root} '
  79. RPROMPT='${cyan}${vcs_info_msg_1_##.|}${vcs_info_msg_2_}%f${last_command_failed}'
  80. emotty_title() {
  81. title "${${?/[^0]*/$warn_prompt $?}/0/${prompt_glyph}}"
  82. }
  83. add-zsh-hook precmd emotty_title
  84. add-zsh-hook precmd vcs_info
  85. # vim:ft=zsh ts=2 sw=2 sts=2