Reputation: 2778
I am trying to tell neovim to kill sxhkd and run sxhkd after I close its config file (sxhkdrc). This is what I have in my init.vim
autocmd BufWritePost *sxhkdrc pkill sxhkd; setsid sxhkd
I get the following error
"sxhkdrc" 9L, 136C written
Error detected while processing BufWritePost Autocommands for "*sxhkdrc":
E492: Not an editor command: pkill sxhkd; setsid sxhkd
Press ENTER or type command to continue
I can run pkill sxhkd; setsid sxhkd
in the terminal without error, but for some reason my init.vim file does not know how to execute this command.
What can I do to kill a processes, such as sxhkd, when I save its config file?
Upvotes: 0
Views: 396
Reputation: 7664
When executing an external command from inside Vim, we use the !
prefix to run the command in a non-interactive shell. You can test this by executing :!ls
for a quick demonstration.
In your case, Vim is informing you that it doesn't understand the command you're giving it. Which is fair enough: it's not an editor command, it's a command designed to be executed from the terminal. You probably want:
autocmd BufWritePost *sxhkdrc !pkill sxhkd; setsid sxhkd
Edit: Alex points out in comments that sxhkd is a daemon, so backgrounding it with &
would make more sense:
autocmd BufWritePost *sxhkdrc !pkill sxhkd && setsid sxhkd &
Upvotes: 1