pyenv.plugin.zsh 929 B

1234567891011121314151617181920212223242526272829303132333435
  1. _homebrew-installed() {
  2. type brew &> /dev/null
  3. }
  4. _pyenv-from-homebrew-installed() {
  5. brew --prefix pyenv &> /dev/null
  6. }
  7. FOUND_PYENV=0
  8. pyenvdirs=("$HOME/.pyenv" "/usr/local/pyenv" "/opt/pyenv")
  9. if _homebrew-installed && _pyenv-from-homebrew-installed ; then
  10. pyenvdirs=($(brew --prefix pyenv) "${pyenvdirs[@]}")
  11. fi
  12. for pyenvdir in "${pyenvdirs[@]}" ; do
  13. if [ -d $pyenvdir/bin -a $FOUND_PYENV -eq 0 ] ; then
  14. FOUND_PYENV=1
  15. export PYENV_ROOT=$pyenvdir
  16. export PATH=${pyenvdir}/bin:$PATH
  17. eval "$(pyenv init - zsh)"
  18. if pyenv commands | command grep -q virtualenv-init; then
  19. eval "$(pyenv virtualenv-init - zsh)"
  20. fi
  21. function pyenv_prompt_info() {
  22. echo "$(pyenv version-name)"
  23. }
  24. fi
  25. done
  26. unset pyenvdir
  27. if [ $FOUND_PYENV -eq 0 ] ; then
  28. function pyenv_prompt_info() { echo "system: $(python -V 2>&1 | cut -f 2 -d ' ')" }
  29. fi