steeef.zsh-theme 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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 '('$fg[blue]`basename $VIRTUAL_ENV`%{$reset_color%}') '
  12. }
  13. PR_GIT_UPDATE=1
  14. setopt prompt_subst
  15. autoload colors
  16. colors
  17. autoload -U add-zsh-hook
  18. autoload -Uz vcs_info
  19. #use extended color pallete if available
  20. if [[ $TERM = *256color* || $TERM = *rxvt* ]]; then
  21. turquoise="%F{81}"
  22. orange="%F{166}"
  23. purple="%F{135}"
  24. hotpink="%F{161}"
  25. limegreen="%F{118}"
  26. else
  27. turquoise="$fg[cyan]"
  28. orange="$fg[yellow]"
  29. purple="$fg[magenta]"
  30. hotpink="$fg[red]"
  31. limegreen="$fg[green]"
  32. fi
  33. # enable VCS systems you use
  34. zstyle ':vcs_info:*' enable git svn
  35. # check-for-changes can be really slow.
  36. # you should disable it, if you work with large repositories
  37. zstyle ':vcs_info:*:prompt:*' check-for-changes true
  38. # set formats
  39. # %b - branchname
  40. # %u - unstagedstr (see below)
  41. # %c - stagedstr (see below)
  42. # %a - action (e.g. rebase-i)
  43. # %R - repository path
  44. # %S - path in the repository
  45. PR_RST="%{${reset_color}%}"
  46. FMT_BRANCH="(%{$turquoise%}%b%u%c${PR_RST})"
  47. FMT_ACTION="(%{$limegreen%}%a${PR_RST})"
  48. FMT_UNSTAGED="%{$orange%}●"
  49. FMT_STAGED="%{$limegreen%}●"
  50. zstyle ':vcs_info:*:prompt:*' unstagedstr "${FMT_UNSTAGED}"
  51. zstyle ':vcs_info:*:prompt:*' stagedstr "${FMT_STAGED}"
  52. zstyle ':vcs_info:*:prompt:*' actionformats "${FMT_BRANCH}${FMT_ACTION}"
  53. zstyle ':vcs_info:*:prompt:*' formats "${FMT_BRANCH}"
  54. zstyle ':vcs_info:*:prompt:*' nvcsformats ""
  55. function steeef_preexec {
  56. case "$(history $HISTCMD)" in
  57. *git*)
  58. PR_GIT_UPDATE=1
  59. ;;
  60. *svn*)
  61. PR_GIT_UPDATE=1
  62. ;;
  63. esac
  64. }
  65. add-zsh-hook preexec steeef_preexec
  66. function steeef_chpwd {
  67. PR_GIT_UPDATE=1
  68. }
  69. add-zsh-hook chpwd steeef_chpwd
  70. function steeef_precmd {
  71. if [[ -n "$PR_GIT_UPDATE" ]] ; then
  72. # check for untracked files or updated submodules, since vcs_info doesn't
  73. if git ls-files --other --exclude-standard 2> /dev/null | grep -q "."; then
  74. PR_GIT_UPDATE=1
  75. FMT_BRANCH="(%{$turquoise%}%b%u%c%{$hotpink%}●${PR_RST})"
  76. else
  77. FMT_BRANCH="(%{$turquoise%}%b%u%c${PR_RST})"
  78. fi
  79. zstyle ':vcs_info:*:prompt:*' formats "${FMT_BRANCH} "
  80. vcs_info 'prompt'
  81. PR_GIT_UPDATE=
  82. fi
  83. }
  84. add-zsh-hook precmd steeef_precmd
  85. PROMPT=$'
  86. %{$purple%}%n%{$reset_color%} at %{$orange%}%m%{$reset_color%} in %{$limegreen%}%~%{$reset_color%} $vcs_info_msg_0_$(virtualenv_info)%{$reset_color%}
  87. $ '