从bashrc中的bash检测neovim终端


13

neovim是否设置了任何可让我从bash中检测到终端为neovim的环境变量?.bashrc如果neovim是终端,我想更改我的行为。

Answers:


15

我将env在标准终端中运行的输出与在Neovim中运行时的输出进行了比较,看起来这些变量是新的:

VIMRUNTIME=/usr/local/Cellar/neovim/HEAD/share/nvim/runtime
VIM=/usr/local/Cellar/neovim/HEAD/share/nvim
NVIM_LISTEN_ADDRESS=/var/folders/_8/sy7jjpw55mbgn2prml0fbsgc0000gn/T/nvimaLHjPR/0

vim我也有$VIM$VIMRUNTIME所以他们的存在并不表示Neovim vs Vim ...)


10

除了alxndr的示例之外,您还可以设置自己:

:let $IN_NEOVIM = "yes"
:terminal
$ env | grep NEOVIM
IN_NEOVIM=yes

作为将信息传递到Shell的简单方法,这特别有用。例如:

:let $NEOVIM_FILETYPE = &filetype
:terminal
$ env | grep NEOVIM
NEOVIM_FILETYPE=python    
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.