Does neovim set any environment variables that would let me detect from bash that the terminal is neovim? I want to change the behavior of my .bashrc if neovim is the terminal.
Asked
Active
Viewed 1,752 times
13
Praxeolitic
- 2,468
- 2
- 15
- 28
2 Answers
16
I compared the output of running env in a standard terminal to the output when running it within Neovim, and it looks like these variables are new:
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
(The vim I have also has $VIM and $VIMRUNTIME so their mere presence doesn't indicate Neovim vs Vim...)
alxndr
- 1,346
- 1
- 15
- 26
11
Aside from alxndr's example, you can set one yourself with:
:let $IN_NEOVIM = "yes"
:terminal
$ env | grep NEOVIM
IN_NEOVIM=yes
This is especially useful as a simple way to pass information to the shell; for example:
:let $NEOVIM_FILETYPE = &filetype
:terminal
$ env | grep NEOVIM
NEOVIM_FILETYPE=python
Martin Tournoij
- 62,054
- 25
- 192
- 271