zsh/plugins/pyenv/pyenv.plugin.zsh

29 lines
1,008 B
Bash
Raw Normal View History

2021-02-26 16:25:55 +00:00
export PYENV_ROOT=${XDG_DATA_HOME:-$HOME/.local/share}/pyenv
_init_pyenv() {
2021-06-21 10:12:53 +00:00
unfunction pyenv
2021-12-03 14:09:12 +00:00
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"
2021-02-26 16:25:55 +00:00
eval "$(pyenv init -)"
2021-12-03 14:09:12 +00:00
source $(pyenv root)/completions/pyenv.zsh
2021-02-26 16:25:55 +00:00
if pyenv commands | grep -q 'virtualenv'; then
eval "$(pyenv virtualenv-init -)"
fi
}
if [[ -d $PYENV_ROOT ]]; then
2021-06-18 10:10:01 +00:00
pyenv() {
_init_pyenv
pyenv $@
}
2021-02-26 16:25:55 +00:00
else
pyenv() {
echo -n "pyenv is not installed. Install now? [yn] "; read -q || return
git clone https://github.com/pyenv/pyenv.git $PYENV_ROOT
2023-03-02 15:11:04 +00:00
git clone https://github.com/pyenv/pyenv-update.git $PYENV_ROOT/plugins/pyenv-update
git clone https://github.com/pyenv/pyenv-virtualenv.git $PYENV_ROOT/plugins/pyenv-virtualenv
git clone https://github.com/jawshooah/pyenv-default-packages.git $PYENV_ROOT/plugins/pyenv-default-packages
git clone https://github.com/fizista/pyenv-choice.git $PYENV_ROOT/plugins/pyenv-choice
echo ptpython > $PYENV_ROOT/default-packages
2021-02-26 16:25:55 +00:00
_init_pyenv
}
fi