How to Detect that Current (Bash) Shell is a (Vi/Vim) Subshell?

Posted by Jeet on Super User See other posts from Super User or by Jeet
Published on 2010-03-26T22:27:28Z Indexed on 2010/03/26 22:33 UTC
Read the original article Hit count: 234

Filed under:
|
|

From inside Vi/Vim, I can type:

:shell

to drop into a shell.

Is there any way to detect that I am in a Vi-spawned subshell?

The environmental variable SHLVL is 2, but that does not tell me explicitly that I am in a Vi/Vim-spawned subshell.

On OS X, the following variables are also set: MYVIMRC, VIMRUNTIME, VIM.

How universal are these? Can I count on these being set in any system, if and only if I am in a Vi/Vim subshell?

If not, is there any portable, robust and hopefully efficient way to tell that I am in a Vi/Vim subshell?

Thanks.

© Super User or respective owner

Related posts about vim

Related posts about bash