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
On
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 (likebashorzsh) as well as thefishshell.pyenvis 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 theevalcommand.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 thepyenvfunction.If run in a
fishshell,pyenv init -returns code that does the same, but infish's syntax.-
For
pyenvto work withxonshit 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-initandlibexec/pyenv-sh-shell(and probably some plugins) for that.