pyenv: initialize only on demand

This commit is contained in:
crater2150 2021-06-18 12:10:01 +02:00
parent 6bd8dd336c
commit 219f5a0523

View file

@ -1,5 +1,6 @@
export PYENV_ROOT=${XDG_DATA_HOME:-$HOME/.local/share}/pyenv export PYENV_ROOT=${XDG_DATA_HOME:-$HOME/.local/share}/pyenv
_init_pyenv() { _init_pyenv() {
unfunction _pyenv
export PATH="$PATH:$PYENV_ROOT/bin" export PATH="$PATH:$PYENV_ROOT/bin"
eval "$(pyenv init -)" eval "$(pyenv init -)"
if pyenv commands | grep -q 'virtualenv'; then if pyenv commands | grep -q 'virtualenv'; then
@ -7,7 +8,10 @@ _init_pyenv() {
fi fi
} }
if [[ -d $PYENV_ROOT ]]; then if [[ -d $PYENV_ROOT ]]; then
pyenv() {
_init_pyenv _init_pyenv
pyenv $@
}
else else
pyenv() { pyenv() {
echo -n "pyenv is not installed. Install now? [yn] "; read -q || return echo -n "pyenv is not installed. Install now? [yn] "; read -q || return