pyenv.plugin.zsh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. for pyenvdir in "${pyenvdirs[@]}" ; do
  10. if [ -d $pyenvdir/bin -a $FOUND_PYENV -eq 0 ] ; then
  11. FOUND_PYENV=1
  12. export PYENV_ROOT=$pyenvdir
  13. export PATH=${pyenvdir}/bin:$PATH
  14. eval "$(pyenv init - zsh)"
  15. if pyenv commands | command grep -q virtualenv-init; then
  16. eval "$(pyenv virtualenv-init - zsh)"
  17. fi
  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. pyenvdir=$(brew --prefix pyenv 2> /dev/null)
  26. if [ $? -eq 0 -a -d $pyenvdir/bin ] ; then
  27. FOUND_PYENV=1
  28. export PYENV_ROOT=$pyenvdir
  29. export PATH=${pyenvdir}/bin:$PATH
  30. eval "$(pyenv init - zsh)"
  31. if pyenv commands | command grep -q virtualenv-init; then
  32. eval "$(pyenv virtualenv-init - zsh)"
  33. fi
  34. function pyenv_prompt_info() {
  35. echo "$(pyenv version-name)"
  36. }
  37. fi
  38. fi
  39. if [ $FOUND_PYENV -eq 0 ] ; then
  40. function pyenv_prompt_info() { echo "system: $(python -V 2>&1 | cut -f 2 -d ' ')" }
  41. fi