terminal vim not loading .zshrc

谁说胖子不能爱 提交于 2019-12-22 01:52:00

问题


My terminal vim configuration is not loading the ~/.zshrc. Zsh is the environment login shell. What is the proper configuration for this situation?

Here are some measures I've already taken and since removed:

set shell=zsh
(uses zsh as shell but doesn't source the rc)

set shellcmdflag=-ci
(all output suspended)

cat ~/.zshenv
$ source ~/.zshrc
(many errors when opening vim)


回答1:


From the manual:

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.

From what I understand,

set shell=zsh\ -i

should work.




回答2:


The accepted answer doesn't work as expected. The actual solution should be putting the aliases and other ~/.zshrc content into ~/.zshenv. The only thing needed in ~/.vimrc is set shell=zsh without any flags.




回答3:


I found an handy solution. As the only thing I really need is all my aliases, I added a function to my ~/.zshrc file:

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

Then execute source ~/.zshrc && zshalias.

In your vimrc you only need:

shell=zsh

Everything then works perfectly with no suspended tty output!



来源:https://stackoverflow.com/questions/11415428/terminal-vim-not-loading-zshrc

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!