steeef.zsh-theme 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 colors
  15. colors
  16. autoload -U add-zsh-hook
  17. autoload -Uz vcs_info
  18. # enable VCS systems you use
  19. zstyle ':vcs_info:*' enable git svn
  20. # check-for-changes can be really slow.
  21. # you should disable it, if you work with large repositories
  22. zstyle ':vcs_info:*:prompt:*' check-for-changes true
  23. # set formats
  24. # %b - branchname
  25. # %u - unstagedstr (see below)
  26. # %c - stagedstr (see below)
  27. # %a - action (e.g. rebase-i)
  28. # %R - repository path
  29. # %S - path in the repository
  30. PR_RST="%{${reset_color}%}"
  31. FMT_BRANCH="(%{$fg[magenta]%}%b%u%c${PR_RST})"
  32. FMT_ACTION="(%{$fg[green]%}%a${PR_RST})"
  33. FMT_UNSTAGED="%{$fg[yellow]%}●"
  34. FMT_STAGED="%{$fg[green]%}●"
  35. zstyle ':vcs_info:*:prompt:*' unstagedstr "${FMT_UNSTAGED}"
  36. zstyle ':vcs_info:*:prompt:*' stagedstr "${FMT_STAGED}"
  37. zstyle ':vcs_info:*:prompt:*' actionformats "${FMT_BRANCH}${FMT_ACTION}"
  38. zstyle ':vcs_info:*:prompt:*' formats "${FMT_BRANCH}"
  39. zstyle ':vcs_info:*:prompt:*' nvcsformats ""
  40. function steeef_preexec {
  41. case "$(history $HISTCMD)" in
  42. *git*)
  43. PR_GIT_UPDATE=1
  44. ;;
  45. *svn*)
  46. PR_GIT_UPDATE=1
  47. ;;
  48. esac
  49. }
  50. add-zsh-hook preexec steeef_preexec
  51. function steeef_chpwd {
  52. PR_GIT_UPDATE=1
  53. }
  54. add-zsh-hook chpwd steeef_chpwd
  55. function steeef_precmd {
  56. # check for untracked files or updated submodules, since vcs_info doesn't
  57. if [[ ! -z $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then
  58. PR_GIT_UPDATE=1
  59. FMT_BRANCH="(%{$fg[magenta]%}%b%u%c%{$fg[red]%}●${PR_RST})"
  60. else
  61. FMT_BRANCH="(%{$fg[magenta]%}%b%u%c${PR_RST})"
  62. fi
  63. zstyle ':vcs_info:*:prompt:*' formats "${FMT_BRANCH}"
  64. if [[ -n "$PR_GIT_UPDATE" ]] ; then
  65. vcs_info 'prompt'
  66. PR_GIT_UPDATE=
  67. fi
  68. }
  69. add-zsh-hook precmd steeef_precmd
  70. PROMPT=$'
  71. %{$fg[magenta]%}%n%{$reset_color%} at %{$fg[yellow]%}%m%{$reset_color%} in %{$fg_bold[green]%}%~%{$reset_color%} $vcs_info_msg_0_
  72. $(virtualenv_info)$ '