steeef.zsh-theme 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. # prompt style and colors based on Steve Losh's Prose theme:
  2. # http://github.com/sjl/oh-my-zsh/blob/master/themes/prose.zsh-theme
  3. #
  4. # vcs_info modifications from Bart Trojanowski's zsh prompt:
  5. # http://www.jukie.net/bart/blog/pimping-out-zsh-prompt
  6. #
  7. # git untracked files modification from Brian Carper:
  8. # http://briancarper.net/blog/570/git-info-in-your-zsh-prompt
  9. export VIRTUAL_ENV_DISABLE_PROMPT=1
  10. function virtualenv_info {
  11. [ $VIRTUAL_ENV ] && echo '('%F{blue}`basename $VIRTUAL_ENV`%f') '
  12. }
  13. PR_GIT_UPDATE=1
  14. setopt prompt_subst
  15. autoload -U add-zsh-hook
  16. autoload -Uz vcs_info
  17. #use extended color palette if available
  18. if [[ $terminfo[colors] -ge 256 ]]; then
  19. turquoise="%F{81}"
  20. orange="%F{166}"
  21. purple="%F{135}"
  22. hotpink="%F{161}"
  23. limegreen="%F{118}"
  24. else
  25. turquoise="%F{cyan}"
  26. orange="%F{yellow}"
  27. purple="%F{magenta}"
  28. hotpink="%F{red}"
  29. limegreen="%F{green}"
  30. fi
  31. # enable VCS systems you use
  32. zstyle ':vcs_info:*' enable git svn
  33. # check-for-changes can be really slow.
  34. # you should disable it, if you work with large repositories
  35. zstyle ':vcs_info:*:prompt:*' check-for-changes true
  36. # set formats
  37. # %b - branchname
  38. # %u - unstagedstr (see below)
  39. # %c - stagedstr (see below)
  40. # %a - action (e.g. rebase-i)
  41. # %R - repository path
  42. # %S - path in the repository
  43. PR_RST="%f"
  44. FMT_BRANCH="(%{$turquoise%}%b%u%c${PR_RST})"
  45. FMT_ACTION="(%{$limegreen%}%a${PR_RST})"
  46. FMT_UNSTAGED="%{$orange%}●"
  47. FMT_STAGED="%{$limegreen%}●"
  48. zstyle ':vcs_info:*:prompt:*' unstagedstr "${FMT_UNSTAGED}"
  49. zstyle ':vcs_info:*:prompt:*' stagedstr "${FMT_STAGED}"
  50. zstyle ':vcs_info:*:prompt:*' actionformats "${FMT_BRANCH}${FMT_ACTION}"
  51. zstyle ':vcs_info:*:prompt:*' formats "${FMT_BRANCH}"
  52. zstyle ':vcs_info:*:prompt:*' nvcsformats ""
  53. function steeef_preexec {
  54. case "$2" in
  55. *git*)
  56. PR_GIT_UPDATE=1
  57. ;;
  58. *hub*)
  59. PR_GIT_UPDATE=1
  60. ;;
  61. *svn*)
  62. PR_GIT_UPDATE=1
  63. ;;
  64. esac
  65. }
  66. add-zsh-hook preexec steeef_preexec
  67. function steeef_chpwd {
  68. PR_GIT_UPDATE=1
  69. }
  70. add-zsh-hook chpwd steeef_chpwd
  71. function steeef_precmd {
  72. if [[ -n "$PR_GIT_UPDATE" ]] ; then
  73. # check for untracked files or updated submodules, since vcs_info doesn't
  74. if git ls-files --other --exclude-standard 2> /dev/null | grep -q "."; then
  75. PR_GIT_UPDATE=1
  76. FMT_BRANCH="(%{$turquoise%}%b%u%c%{$hotpink%}●${PR_RST})"
  77. else
  78. FMT_BRANCH="(%{$turquoise%}%b%u%c${PR_RST})"
  79. fi
  80. zstyle ':vcs_info:*:prompt:*' formats "${FMT_BRANCH} "
  81. vcs_info 'prompt'
  82. PR_GIT_UPDATE=
  83. fi
  84. }
  85. add-zsh-hook precmd steeef_precmd
  86. PROMPT=$'
  87. %{$purple%}%n${PR_RST} at %{$orange%}%m${PR_RST} in %{$limegreen%}%~${PR_RST} $vcs_info_msg_0_$(virtualenv_info)
  88. $ '