prompt_skwp_setup 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #
  2. # A single line theme with Git information on the left and Ruby on the right.
  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. # Yan Pritzker <yan@pritzker.ws>
  11. #
  12. # Screenshots:
  13. # http://i.imgur.com/gLgVp6Y.png
  14. #
  15. function prompt_skwp_precmd {
  16. # Get Git repository information.
  17. if (( $+functions[git-info] )); then
  18. git-info
  19. fi
  20. # Get Ruby information.
  21. if (( $+functions[ruby-info] )); then
  22. ruby-info
  23. fi
  24. }
  25. function prompt_skwp_setup {
  26. setopt LOCAL_OPTIONS
  27. unsetopt XTRACE KSH_ARRAYS
  28. prompt_opts=(cr percent sp subst)
  29. # Load required functions.
  30. autoload -Uz add-zsh-hook
  31. # Add hook to set up prompt parameters before each command.
  32. add-zsh-hook precmd prompt_skwp_precmd
  33. # Tell prezto we can manage this prompt
  34. zstyle ':prezto:module:prompt' managed 'yes'
  35. # Use extended color pallete if available.
  36. if [[ $TERM = *256color* || $TERM = *rxvt* ]]; then
  37. _prompt_skwp_colors=(
  38. "%F{81}" # Turquoise
  39. "%F{166}" # Orange
  40. "%F{135}" # Purple
  41. "%F{161}" # Hotpink
  42. "%F{118}" # Limegreen
  43. )
  44. else
  45. _prompt_skwp_colors=(
  46. "%F{cyan}"
  47. "%F{yellow}"
  48. "%F{magenta}"
  49. "%F{red}"
  50. "%F{green}"
  51. )
  52. fi
  53. # Set git-info parameters.
  54. zstyle ':prezto:module:git:info' verbose 'yes'
  55. zstyle ':prezto:module:git:info:branch' format "${_prompt_skwp_colors[1]}%b%f"
  56. zstyle ':prezto:module:git:info:added' format "${_prompt_skwp_colors[5]}●%f"
  57. zstyle ':prezto:module:git:info:deleted' format "${_prompt_skwp_colors[2]}●%f"
  58. zstyle ':prezto:module:git:info:modified' format "${_prompt_skwp_colors[4]}●%f"
  59. zstyle ':prezto:module:git:info:untracked' format "${_prompt_skwp_colors[3]}●%f"
  60. zstyle ':prezto:module:git:info:keys' format 'prompt' '(%b%d%a%m%u)'
  61. # Set ruby-info parameters.
  62. zstyle ':prezto:module:ruby:info:version' format '[%v]'
  63. # Define prompts.
  64. PROMPT="${_prompt_skwp_colors[3]}%n%f@${_prompt_skwp_colors[2]}%m%f ${_prompt_skwp_colors[5]}%~%f "'${git_info:+${(e)git_info[prompt]}}'"$ "
  65. RPROMPT='%F{blue}${ruby_info[version]}'
  66. }
  67. prompt_skwp_setup "$@"
  68. # vim: ft=zsh