prompt_info_functions.zsh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # *_prompt_info functions for usage in your prompt
  2. #
  3. # Plugin creators, please add your *_prompt_info function to the list
  4. # of dummy implementations to help theme creators not receiving errors
  5. # without the need of implementing conditional clauses.
  6. #
  7. # See also lib/bzr.zsh, lib/git.zsh and lib/nvm.zsh for
  8. # git_prompt_info, bzr_prompt_info and nvm_prompt_info
  9. # Dummy implementations that return false to prevent command_not_found
  10. # errors with themes, that implement these functions
  11. # Real implementations will be used when the respective plugins are loaded
  12. function chruby_prompt_info \
  13. rbenv_prompt_info \
  14. hg_prompt_info \
  15. pyenv_prompt_info \
  16. svn_prompt_info \
  17. vi_mode_prompt_info \
  18. virtualenv_prompt_info \
  19. jenv_prompt_info \
  20. {
  21. return 1
  22. }
  23. # oh-my-zsh supports an rvm prompt by default
  24. # get the name of the rvm ruby version
  25. function rvm_prompt_info() {
  26. [ -f $HOME/.rvm/bin/rvm-prompt ] || return 1
  27. local rvm_prompt
  28. rvm_prompt=$($HOME/.rvm/bin/rvm-prompt ${=ZSH_THEME_RVM_PROMPT_OPTIONS} 2>/dev/null)
  29. [[ -z "${rvm_prompt}" ]] && return 1
  30. echo "${ZSH_THEME_RUBY_PROMPT_PREFIX}${rvm_prompt}${ZSH_THEME_RUBY_PROMPT_SUFFIX}"
  31. }
  32. ZSH_THEME_RVM_PROMPT_OPTIONS="i v g"
  33. # use this to enable users to see their ruby version, no matter which
  34. # version management system they use
  35. function ruby_prompt_info() {
  36. echo $(rvm_prompt_info || rbenv_prompt_info || chruby_prompt_info)
  37. }