prompt_steeef_setup 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #
  2. # A theme based on Steve Losh's Extravagant Prompt with vcs_info integration.
  3. #
  4. # Authors:
  5. # Steve Losh <steve@stevelosh.com>
  6. # Bart Trojanowski <bart@jukie.net>
  7. # Brian Carper <brian@carper.ca>
  8. # steeef <steeef@gmail.com>
  9. # Sorin Ionescu <sorin.ionescu@gmail.com>
  10. #
  11. # Screenshots:
  12. # http://i.imgur.com/HyRvv.png
  13. #
  14. function prompt_steeef_precmd {
  15. # Check for untracked files or updated submodules since vcs_info does not.
  16. if [[ -n $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then
  17. branch_format="(${_prompt_steeef_colors[1]}%b%f%u%c${_prompt_steeef_colors[4]}●%f)"
  18. else
  19. branch_format="(${_prompt_steeef_colors[1]}%b%f%u%c)"
  20. fi
  21. zstyle ':vcs_info:*:prompt:*' formats "${branch_format}"
  22. vcs_info 'prompt'
  23. if (( $+functions[python-info] )); then
  24. python-info
  25. fi
  26. }
  27. function prompt_steeef_setup {
  28. setopt LOCAL_OPTIONS
  29. unsetopt XTRACE KSH_ARRAYS
  30. prompt_opts=(cr percent sp subst)
  31. # Load required functions.
  32. autoload -Uz add-zsh-hook
  33. autoload -Uz vcs_info
  34. # Add hook for calling vcs_info before each command.
  35. add-zsh-hook precmd prompt_steeef_precmd
  36. # Tell prezto we can manage this prompt
  37. zstyle ':prezto:module:prompt' managed 'yes'
  38. # Use extended color pallete if available.
  39. if [[ $TERM = *256color* || $TERM = *rxvt* ]]; then
  40. _prompt_steeef_colors=(
  41. "%F{81}" # Turquoise
  42. "%F{166}" # Orange
  43. "%F{135}" # Purple
  44. "%F{161}" # Hotpink
  45. "%F{118}" # Limegreen
  46. )
  47. else
  48. _prompt_steeef_colors=(
  49. "%F{cyan}"
  50. "%F{yellow}"
  51. "%F{magenta}"
  52. "%F{red}"
  53. "%F{green}"
  54. )
  55. fi
  56. # Formats:
  57. # %b - branchname
  58. # %u - unstagedstr (see below)
  59. # %c - stagedstr (see below)
  60. # %a - action (e.g. rebase-i)
  61. # %R - repository path
  62. # %S - path in the repository
  63. local branch_format="(${_prompt_steeef_colors[1]}%b%f%u%c)"
  64. local action_format="(${_prompt_steeef_colors[5]}%a%f)"
  65. local unstaged_format="${_prompt_steeef_colors[2]}●%f"
  66. local staged_format="${_prompt_steeef_colors[5]}●%f"
  67. # Set editor-info parameters.
  68. zstyle ':prezto:module:editor:info:keymap:primary' format '$'
  69. # Set vcs_info parameters.
  70. zstyle ':vcs_info:*' enable bzr git hg svn
  71. zstyle ':vcs_info:*:prompt:*' check-for-changes true
  72. zstyle ':vcs_info:*:prompt:*' unstagedstr "${unstaged_format}"
  73. zstyle ':vcs_info:*:prompt:*' stagedstr "${staged_format}"
  74. zstyle ':vcs_info:*:prompt:*' actionformats "${branch_format}${action_format}"
  75. zstyle ':vcs_info:*:prompt:*' formats "${branch_format}"
  76. zstyle ':vcs_info:*:prompt:*' nvcsformats ""
  77. # Set python-info parameters.
  78. zstyle ':prezto:module:python:info:virtualenv' format '(%v)'
  79. # Define prompts.
  80. PROMPT="
  81. ${_prompt_steeef_colors[3]}%n%f at ${_prompt_steeef_colors[2]}%m%f in ${_prompt_steeef_colors[5]}%~%f "'${vcs_info_msg_0_}'"
  82. "'$python_info[virtualenv]${editor_info[keymap]} '
  83. RPROMPT=''
  84. }
  85. function prompt_steeef_preview {
  86. local +h PROMPT=''
  87. local +h RPROMPT=''
  88. local +h SPROMPT=''
  89. editor-info 2> /dev/null
  90. prompt_preview_theme 'steeef'
  91. }
  92. prompt_steeef_setup "$@"
  93. # vim: ft=zsh