Deactivate or de-init #2743
-
I've just started to use pyenv (installed via homebrew) and have a question about "activating/deactivating" According to docs, i set up export XDG_DATA_HOME="${XDG_DATA_HOME:-~/.local/share}"
export PYENV_ROOT="${XDG_DATA_HOME}/pyenv" That's ok. Next, i should add eval "$(eval pyenv -i)" # or --path into my .zshrc/.bashrc files and it's a bit tricky - i already have latest python installed (via homebrew either) and wanna keep it as global and be able to switching on/off pyenv'ed python. E.g. ~ ✔ $ which python3
/opt/homebrew/bin/python3
~ ✔ $ eval "$(pyenv init -)"
~ ✔ $ which python3
/Users/tonysol/.local/share/pyenv/shims/python3 what command should i run next to exec just ~ ✔ $ PATH="$(bash --norc -ec 'IFS=:; paths=($PATH);
for i in ${!paths[@]}; do
if [[ ${paths[i]} == "''/Users/tonysol/.local/share/pyenv/shims''" ]]; then unset '\''paths[i]'\'';
fi; done;
echo "${paths[*]}"')" part of init command? UPD: ofk it can be alias, but i'm looking for 'native' solution :) UPD: looks like is |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
See the installation section in the README. To follow the XDG spec, set |
Beta Was this translation helpful? Give feedback.
-
$ which python3
/Users/tonysol/.local/share/pyenv/shims/python3 This is fine. Unless you specifically select a Pyenv-installed Python version, shims act as if they weren't on PATH. Use A shim runs whichever Python is currently configured. The default is |
Beta Was this translation helpful? Give feedback.
There's no need to "deinit" in the above-described scenario; you only need to replace
which
withpyenv which
to see what real executable would be run.That's nevertheless possible with a plugin.
Create an executable
$PYENV_ROOT/plugins/<plugin-name>/bin/pyenv-sh-deinit
.It will be called when executing
pyenv deinit
whenpyenv
is installed as a shell function.It should output commands to be executed in the current shell. Those need to do the reverse of what
pyenv init
does as per https://github.com/pyenv/pyenv#advanced-configuration .It should also handle the
--complete
argument, printing possible continuations for shell completion (none in this case, most probably).