prompt_nicoulaj_setup 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #
  2. # A simple theme that displays only relevant information.
  3. #
  4. # Authors:
  5. # Julien Nicoulaud <julien.nicoulaud@gmail.com>
  6. # Sorin Ionescu <sorin.ionescu@gmail.com>
  7. #
  8. # Features:
  9. # - One line.
  10. # - VCS information in the right prompt.
  11. # - Only shows the path on the left prompt by default.
  12. # - Crops the path to a defined length and only shows the path relative to
  13. # the current VCS repository root.
  14. # - Uses a different color depending on if the last command succeeded/failed.
  15. # - Shows user@hostname if connected through SSH.
  16. # - Shows if logged in as root or not.
  17. #
  18. # Screenshots:
  19. # http://i.imgur.com/Xe1bu.png
  20. #
  21. function prompt_nicoulaj_precmd {
  22. vcs_info
  23. }
  24. function prompt_nicoulaj_setup {
  25. setopt LOCAL_OPTIONS
  26. unsetopt XTRACE KSH_ARRAYS
  27. prompt_opts=(cr percent sp subst)
  28. # Load required functions.
  29. autoload -Uz add-zsh-hook
  30. autoload -Uz vcs_info
  31. # Add hook for calling vcs_info before each command.
  32. add-zsh-hook precmd prompt_nicoulaj_precmd
  33. # Tell prezto we can manage this prompt
  34. zstyle ':prezto:module:prompt' managed 'yes'
  35. # Customizable parameters.
  36. local max_path_chars=30
  37. local user_char='❯'
  38. local root_char='❯❯❯'
  39. local success_color='%F{071}'
  40. local failure_color='%F{124}'
  41. local vcs_info_color='%F{242}'
  42. # Set vcs_info parameters.
  43. zstyle ':vcs_info:*' enable bzr git hg svn
  44. zstyle ':vcs_info:*' check-for-changes true
  45. zstyle ':vcs_info:*' unstagedstr '!'
  46. zstyle ':vcs_info:*' stagedstr '+'
  47. zstyle ':vcs_info:*' actionformats "%S" "%r/%s/%b %u%c (%a)"
  48. zstyle ':vcs_info:*' formats "%S" "%r/%s/%b %u%c"
  49. zstyle ':vcs_info:*' nvcsformats "%~" ""
  50. # Define prompts.
  51. PROMPT="%(?.${success_color}.${failure_color})${SSH_TTY:+[%n@%m]}%B%${max_path_chars}<...<"'${vcs_info_msg_0_%%.}'"%<<%(!.${root_char}.${user_char})%b%f "
  52. RPROMPT="${vcs_info_color}"'${vcs_info_msg_1_}'"%f"
  53. }
  54. prompt_nicoulaj_setup "$@"
  55. # vim: ft=zsh