From fe0079b3e2067aca0faee2f4238b18b08593f44f Mon Sep 17 00:00:00 2001 From: "Lucas F." Date: Wed, 8 May 2024 09:21:02 -0300 Subject: [PATCH] initial --- pyenv_lazy.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 pyenv_lazy.sh diff --git a/pyenv_lazy.sh b/pyenv_lazy.sh new file mode 100644 index 0000000..4bbc059 --- /dev/null +++ b/pyenv_lazy.sh @@ -0,0 +1,23 @@ +# 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