Reputation: 334
I often use the :sh command while using vim (to do a grep for example).
But sometimes I forgot I had a vim running behind my shell.
Is there a command to detect that I have a vim running behind my shell?
Upvotes: 5
Views: 178
Reputation: 9312
You could check the parent process:
$ ps -p $PPID -o cmd=
vi file
Or to be independent of environment variables:
$ ps -p $(ps -p $$ -o ppid=) -o cmd=
vi file
Upvotes: 0
Reputation: 196816
You can see if Vim-specific shell variables are set:
$ echo $VIM
$ echo $VIMRUNTIME
$ echo $MYVIMRC
Upvotes: 3
Reputation: 5503
You should have an environment variable set called VIM
, you can see if this is then set
$ echo $VIM
Note, it's also possible (unlikely) that $VIM is set when you're just in your shell normally.
Upvotes: 2