pyenv_lazy/pyenv_lazy.sh
2024-05-08 09:21:02 -03:00

23 lines
801 B
Bash

# Try to find pyenv, if it's not on the path
#https://github.com/davidparsson/zsh-pyenv-lazy
#https://github.com/Ttayu/zsh-pyenv-lazy/tree/fix/prevent_overwriting_path
export PYENV_ROOT="${PYENV_ROOT:=${HOME}/.pyenv}"
if ! type pyenv > /dev/null && [ -f "${PYENV_ROOT}/bin/pyenv" ]; then
export PATH="${PYENV_ROOT}/bin:${PATH}"
fi
# Lazy load pyenv
if type pyenv > /dev/null; then
# export PATH="${PYENV_ROOT}/bin:${PYENV_ROOT}/shims:${PATH}"
if [[ ! -n "${VIRTUAL_ENV}" ]]; then
export PATH="${PYENV_ROOT}/bin:${PYENV_ROOT}/shims:${PATH}"
fi
function pyenv() {
unset -f pyenv
eval "$(command pyenv init -)"
if [[ -n "${ZSH_PYENV_LAZY_VIRTUALENV}" ]]; then
eval "$(command pyenv virtualenv-init -)"
fi
pyenv $@
}
fi