In vi, I can get a shell terminal with :sh command. And later, I can return to vi by exit shell.But, if I was using the shell terminal for a long time, and I forgot whether exit will close anything or return me the vi.Is there any way to check whether I will return to vi? jobs or fg is not working.
How do I know i am in a shell from vi command :sh?
external command
In a regular shell:$ env | grep -i vimEDITOR=vimAfter using :shell$ env | grep -i vimEDITOR=vimVIMRUNTIME=/usr/share/vim/vim80VIM=/usr/share/vimMYVIMRC=/home/martin/.vim/vimrcSo it looks like Vim sets the VIMRUNTIME, VIM, and MYVIMRC environment variables. Of those, VIM seems the most reliable to me (you may not have a vimrc or even vim runtime).You can also set your own environment variables::let $HELLO = test:shell$ echo $HELLOtestThis is especially useful to communicate info about the buffer you're editing; for example::let $VIM_FILETYPE = &filetype:let $VIM_FILENAME = expand('%:p')Will show up as something like:VIM_FILETYPE=goVIM_FILENAME=/home/martin/a.go