Note: This answer only seems to work with the
fish shells. I also tried
zsh, and it doesn't work there; I'm not sure why, because if I do the same actions from these shells without Vim, it does work as expected... (
:! commands are executed though the shell).
I happen to use
tcsh, so it works for me...
You can use
:set shell=/bin/tcsh to set your shell; this is global, though. So only use it if you think this is a very important feature :-)
^Z send a
SIGTSTP signal, you can send this signal with
kill, and then use
SIGCONT to continue (resume) the process. This will detach the process from Vim.
Because it's difficult to show with this
sleep (how do you know it has continued execution?), I'll use
gitk as an example (but any GUI program will do):
For example in Vim:
And then in another terminal:
$ ps ax | grep gitk
30105 pts/10 S+ 0:00 -bin/tcsh -c gitk
30108 pts/10 Sl+ 0:00 wish /sbin/gitk --
$ kill -TSTP 30108
$ kill -CONT 30108
You can of course also use
pkill; for example:
$ killall -TSTP wish
$ killall -CONST wish
You do need to open another terminal for this, which is not ideal, but it will allow you to continue using both your Vim and your external process.