pyenv.plugin.zsh 813 B

12345678910111213141516171819202122232425262728293031
  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 --no-rehash - zsh)"
  18. function pyenv_prompt_info() {
  19. echo "$(pyenv version-name)"
  20. }
  21. fi
  22. done
  23. unset pyenvdir
  24. if [ $FOUND_PYENV -eq 0 ] ; then
  25. function pyenv_prompt_info() { echo "system: $(python -V 2>&1 | cut -f 2 -d ' ')" }
  26. fi