如何将eval "$(pyenv init -)"
中的.zshrc
移至.xonshrc
?
xonsh
中的语法是什么?
答案 0 :(得分:1)
pyenv
(目前)仅支持符合POSIX标准的shell(如bash
或zsh
)以及fish
shell。 pyenv
不仅仅是python
的包装器,它将自身集成到正在运行的shell会话中,以便透明地提供所需的virtualenv。
eval "$(pyenv init -)"
获取pyenv init -
的输出并在正在运行的shell的上下文中运行(计算)它,就好像输出是在那里而不是eval
命令一样。
看一下pyenv init -
的输出,你可以看到,它是一些shell代码,除其他外,它定义了pyenv
函数。
export PATH="/home/adaephon/local/opt/pyenv/shims:${PATH}"
export PYENV_SHELL=zsh
source '/home/adaephon/local/opt/pyenv/libexec/../completions/pyenv.zsh'
command pyenv rehash 2>/dev/null
pyenv() {
local command
command="$1"
if [ "$#" -gt 0 ]; then
shift
fi
case "$command" in
activate|deactivate|rehash|shell)
eval "$(pyenv "sh-$command" "$@")";;
*)
command pyenv "$command" "$@";;
esac
}
如果在fish
shell中运行,则pyenv init -
会返回执行相同操作但仍采用fish
语法的代码。
-
要pyenv
使用xonsh
,必须输出xonsh
- 兼容的变量和函数定义。据我所知,您必须至少编辑文件libexec/pyenv-init
和libexec/pyenv-sh-shell
(可能还有一些插件)。
答案 1 :(得分:0)
const user = [...document.querySelectorAll('.msg.g_bot.bot.private.i ~ .msg .usr')]
.reduce((userObj, i) => {
if (i.childNodes[0].nodeName !== 'SPAN') return userObj;
const childHtml = i.childNodes[0].innerHTML;
const theUser = userObj[childHtml] || { msg: [] };
theUser.msg.push(i.nextElementSibling.nextElementSibling.innerHTML)
return userObj;
}, {});
会生成一些可以获取的bash代码。 xonsh有一种方法来获取bash代码:pyenv init -
。不幸的是,source-bash
只接受一个文件作为参数;它不消耗STDIN。但解决方案相当简单:
source-bash