Alter $PATH in vim/macvim so as to find the right

2019-02-11 00:46发布

In trying to harmonize environments between a ZSH session and the vim/macvim access of the shell, a which ruby from the shell shows $HOME/.rvm/rubies/ruby-1.9.3/bin/ruby, which is good, while from inside vim/macvim a !which ruby shows /opt/local/bin/ruby, which is bad.

I thought copying the invocation of RVM from .zshrc to .zshenv would work but doing so interferes with other utilities. After several days trying to sort this out, I feel stumped. Any suggestions of where documentation to resolve this can be found would be most appreciated.

3条回答
Lonely孤独者°
2楼-- · 2019-02-11 00:58

I don't know if it applies to zsh but depending on how it's started, bash reads some files and not others. Having this line in my ~/.vimrc ensures that $PATH is the same in Vim and in my shell.

set shell=bash\ -i

But it depends on how you start/customize your shell.

See :help 'shell' and zsh's manual.

查看更多
Fickle 薄情
3楼-- · 2019-02-11 01:05

Maybe :$PATH=$HOME.'/.rvm/rubies/ruby-1.9.3/bin/ruby:'.$PATH in your vimrc. Probably hacky, but maybe it'll work.

查看更多
老娘就宠你
4楼-- · 2019-02-11 01:19

The answer given here worked for me pretty well:

How to use correct ruby in vim ? How to modify $PATH in VIM?

And the explanation given for the different $PATH in interactive and non-interactive mode is straightforward:

https://github.com/dotphiles/dotzsh#mac-os-x

查看更多
登录 后发表回答