From f596d5d1d6f7ff4edefd03749e847fdfd0505654 Mon Sep 17 00:00:00 2001 From: laggardkernel Date: Thu, 25 Apr 2019 16:02:05 +0800 Subject: [PATCH] python: improve PYENV_ROOT detection --- modules/python/init.zsh | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/modules/python/init.zsh b/modules/python/init.zsh index 44043f1..e5967f7 100644 --- a/modules/python/init.zsh +++ b/modules/python/init.zsh @@ -8,17 +8,12 @@ # # Load manually installed pyenv into the path -if [[ -n "$PYENV_ROOT" && -s "$PYENV_ROOT/bin/pyenv" ]]; then - path=("$PYENV_ROOT/bin" $path) -elif [[ -s "$HOME/.pyenv/bin/pyenv" ]]; then - path=("$HOME/.pyenv/bin" $path) -fi +if [[ -s "${PYENV_ROOT:=$HOME/.pyenv}/bin/pyenv" ]]; then + path=("${PYENV_ROOT}/bin" $path) + eval "$(pyenv init - --no-rehash zsh)" # Load pyenv into the current python session -if (( $+commands[pyenv] )); then - if [[ -z "$PYENV_ROOT" ]]; then - export PYENV_ROOT=$(pyenv root) - fi +elif (( $+commands[pyenv] )); then eval "$(pyenv init - --no-rehash zsh)" # Prepend PEP 370 per user site packages directory, which defaults to