Detect vim background after: sh

I often use the : sh command when using vim (e.g. for grep).

But sometimes I forget that I had a vim running after my shell.

Is there a command to detect that I have a vim that works behind my shell?

+5
source share
3 answers

You can see if the Vim shell variables are set:

$ echo $VIM $ echo $VIMRUNTIME $ echo $MYVIMRC 
+3
source

You should have a set of environment variables called VIM , you can see if this value is set

  $ echo $VIM 

Note that it is also possible (unlikely) that $ VIM is installed when you are just in your shell.

+2
source

You can check the parent process:

 $ ps -p $PPID -o cmd= vi file 

Or be independent of environment variables:

 $ ps -p $(ps -p $$ -o ppid=) -o cmd= vi file 
0
source

Source: https://habr.com/ru/post/1206708/


All Articles