jenv.plugin.zsh 739 B

123456789101112131415161718192021222324252627282930
  1. jenvdirs=("$HOME/.jenv" "/usr/local/jenv" "/opt/jenv")
  2. FOUND_JENV=0
  3. for jenvdir in $jenvdirs; do
  4. if [[ -d "${jenvdir}/bin" ]]; then
  5. FOUND_JENV=1
  6. break
  7. fi
  8. done
  9. if [[ $FOUND_JENV -eq 0 ]]; then
  10. if (( $+commands[brew] )) && jenvdir="$(brew --prefix jenv)"; then
  11. [[ -d "${jenvdir}/bin" ]] && FOUND_JENV=1
  12. fi
  13. fi
  14. if [[ $FOUND_JENV -eq 1 ]]; then
  15. export PATH="${jenvdir}/bin:$PATH"
  16. eval "$(jenv init - zsh)"
  17. function jenv_prompt_info() { jenv version-name 2>/dev/null }
  18. if [[ -d "${jenvdir}/versions" ]]; then
  19. export JENV_ROOT=$jenvdir
  20. fi
  21. else
  22. function jenv_prompt_info() { echo "system: $(java -version 2>&1 | cut -f 2 -d ' ')" }
  23. fi
  24. unset jenvdir jenvdirs FOUND_JENV