jnrowe.zsh-theme 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. autoload -U colors && colors
  2. autoload -U add-zsh-hook
  3. autoload -Uz vcs_info
  4. zstyle ':vcs_info:*' actionformats \
  5. '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f '
  6. zstyle ':vcs_info:*' formats \
  7. '%F{2}%s%F{7}:%F{2}(%F{1}%b%F{2})%f '
  8. zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r'
  9. zstyle ':vcs_info:*' enable git
  10. add-zsh-hook precmd prompt_vcs
  11. add-zsh-hook precmd prompt_host
  12. prompt_vcs () {
  13. vcs_info
  14. if [ "${vcs_info_msg_0_}" = "" ]; then
  15. dir_status="%F{2}→%f"
  16. elif [[ $(git diff --cached --name-status 2>/dev/null ) != "" ]]; then
  17. dir_status="%F{1}▶%f"
  18. elif [[ $(git diff --name-status 2>/dev/null ) != "" ]]; then
  19. dir_status="%F{3}▶%f"
  20. else
  21. dir_status="%F{2}▶%f"
  22. fi
  23. }
  24. prompt_host () {
  25. if [[ -n "$SSH_CLIENT" ]]; then
  26. host=" ($HOST)"
  27. else
  28. host=''
  29. fi
  30. }
  31. local ret_status="%(?:%{$fg_bold[green]%}Ξ:%{$fg_bold[red]%}%S↑%s%?)"
  32. PROMPT='${ret_status}%{$fg[blue]%}${host}%{$fg_bold[green]%}%p %{$fg_bold[yellow]%}%2~ ${vcs_info_msg_0_}${dir_status}%{$reset_color%} '
  33. # vim: set ft=zsh ts=4 sw=4 et: