half-life.zsh-theme 2.8 KB

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