将eval $(pyenv init - )从zsh移动到xonsh

时间:2017-05-25 16:28:49

标签: zsh pyenv xonsh

如何将eval "$(pyenv init -)"中的.zshrc移至.xonshrcxonsh中的语法是什么?

2 个答案:

答案 0 :(得分:1)

pyenv(目前)仅支持符合POSIX标准的shell(如bashzsh)以及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-initlibexec/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