问题 终端vim没有加载.zshrc


我的终端vim配置没有加载〜/ .zshrc。 Zsh是环境登录shell。这种情况的正确配置是什么?

以下是我已采取并已删除的一些措施:

set shell=zsh
(使用zsh作为shell但不提供rc)

set shellcmdflag=-ci
(所有输出暂停)

cat ~/.zshenv
$ source ~/.zshrc
(打开vim时出现很多错误)


4990
2017-07-10 14:22


起源



答案:


从手册:

Commands  are  first  read from /etc/zshenv; this cannot be overridden.

[...]

Commands are then read from $ZDOTDIR/.zshenv. If the shell is a
login shell, commands are read from /etc/zprofile and then 
$ZDOTDIR/.zprofile. Then, if the shell is interactive, 
commands are read from /etc/zshrc and then $ZDOTDIR/.zshrc. Finally,
if the shell is a login shell, /etc/zlogin and $ZDOTDIR/.zlogin are
read.

据我所知,

set shell=zsh\ -i

应该管用。


8
2017-07-10 14:56



那是第二个命令 set shellcmdflag=-ci。当我尝试时,所有输出都被暂停。 - Matt Ryan
-ci 要么 -i 是正确的标志。你的意思是vim被暂停,你是在shell的提示?这是Vim在终端中的预期和正常行为。你根本无法改变它。在GVim / MacVim中,做 :!<command> 将命令行扩展为一种愚蠢的终端,供您阅读输出 <command>。如果这是您之后必须切换到GVim / MacVim的行为。 - romainl
随着 ci 要么 c 标志,命令完成类似的东西 21195 suspended (tty output) vim 我留在zsh shell提示符下。然后我必须输入 fg 有预期的结果。 - Nicolas Wormser
不知道为什么这是接受的答案,它不起作用! - slm
@slm手动输入提供了解决问题所需的洞察力。我的问题与命令的读取顺序有关。 - Matt Ryan


答案:


从手册:

Commands  are  first  read from /etc/zshenv; this cannot be overridden.

[...]

Commands are then read from $ZDOTDIR/.zshenv. If the shell is a
login shell, commands are read from /etc/zprofile and then 
$ZDOTDIR/.zprofile. Then, if the shell is interactive, 
commands are read from /etc/zshrc and then $ZDOTDIR/.zshrc. Finally,
if the shell is a login shell, /etc/zlogin and $ZDOTDIR/.zlogin are
read.

据我所知,

set shell=zsh\ -i

应该管用。


8
2017-07-10 14:56



那是第二个命令 set shellcmdflag=-ci。当我尝试时,所有输出都被暂停。 - Matt Ryan
-ci 要么 -i 是正确的标志。你的意思是vim被暂停,你是在shell的提示?这是Vim在终端中的预期和正常行为。你根本无法改变它。在GVim / MacVim中,做 :!<command> 将命令行扩展为一种愚蠢的终端,供您阅读输出 <command>。如果这是您之后必须切换到GVim / MacVim的行为。 - romainl
随着 ci 要么 c 标志,命令完成类似的东西 21195 suspended (tty output) vim 我留在zsh shell提示符下。然后我必须输入 fg 有预期的结果。 - Nicolas Wormser
不知道为什么这是接受的答案,它不起作用! - slm
@slm手动输入提供了解决问题所需的洞察力。我的问题与命令的读取顺序有关。 - Matt Ryan


接受的答案不能按预期工作。实际的解决方案应该是别名和其他 ~/.zshrc 内容成 ~/.zshenv。唯一需要的东西 ~/.vimrc 是 set shell=zsh 没有任何旗帜。


6
2017-12-02 17:57



手动输入提供了解决问题所需的洞察力。我的问题与命令的读取顺序有关。没有提到别名是一个问题。 - Matt Ryan
有点流畅。添加符号链接 ln -s ~/.zshrc ~/.zshenv - Artem Zhukov


我找到了一个方便的解决方案。因为我真正需要的唯一的东西是我的所有别名,我为我添加了一个功能 ~/.zshrc 文件:

function zshalias()
{
  grep "^alias" ~/.zshrc > ~/.zshenv
}

然后执行 source ~/.zshrc && zshalias

在你的vimrc中你只需要:

shell=zsh

一切都很完美,没有暂停的输出!


0
2018-02-10 14:15