How can I move eval "$(pyenv init -)"
that is in .zshrc
to .xonshrc
?
What is the syntax in xonsh
to do that?
Move the eval $(pyenv init -) from zsh to xonsh
1.7k Views Asked by redeemefy At
2
There are 2 best solutions below
1

pyenv init -
generates a bit of bash code that can be sourced. xonsh has a way to source bash code: source-bash
. Unfortunately, source-bash
only takes a file as argument; it doesn't consume STDIN. The solution is fairly simple, though:
pyenv init - > /tmp/pyenv
source-bash /tmp/pyenv > /dev/null
pyenv
(at the moment) only supports POSIX compliant shells (likebash
orzsh
) as well as thefish
shell.pyenv
is not just a wrapper aroundpython
, it integrates itself into the running shell session in order to transparently provide the desired virtualenv.takes the output of
pyenv init -
and runs (evaluates) it in the context of the running shell, just as if the output was written there instead of theeval
command.Having a look at the output of
pyenv init -
you can see, that it is a bit of shell code, that - among other things - defines thepyenv
function.If run in a
fish
shell,pyenv init -
returns code that does the same, but infish
's syntax.-
For
pyenv
to work withxonsh
it would have to outputxonsh
-compatible variable and function definitions. As far as I can see, you would have to at least edit the fileslibexec/pyenv-init
andlibexec/pyenv-sh-shell
(and probably some plugins) for that.