Created
May 24, 2021 13:39
-
-
Save johansenja/2df14daf4c611685c20a81dd3f22d68c to your computer and use it in GitHub Desktop.
Run command in the background in vim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" I ended up using this for starting the long-running qdocs server in qdocs-vim (https://github.com/johansenja/qdocs-vim). | |
" Obviously this requires ruby to spawn the process, but that is ok here given that qdocs is written in ruby anyway | |
" spawn the process and grab the pid to be able to refer to later | |
" --disable=all just speeds up the ruby start time | |
let l:long_running_pid = system("ruby --disable=all -e 'print(spawn(%{long_running_shell_command}))'") | |
" stop the server using the pid from earlier | |
exe "! kill -9 " . l:long_running_pid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment