christoomey / vim-tmux-runner

Vim and tmux, sittin' in a tree...
MIT License
291 stars 37 forks source link

Stop current running process in runner #79

Closed giovannibenussi closed 4 years ago

giovannibenussi commented 6 years ago

It is possible to send a SIGINT or stop a process that is running in the current attached pane.

This can be useful for example when you're coding something in vim that takes some seconds to finish and you want to execute it directly in an attached pane without leave vim. If you realize that you make a mistake, it can be easier to cancel directly the running process without leave vim.

Currently the process is (starting in vim): move to the attached pane, press ctrl-c, go back to vim.

Also, this can be useful to exit copy mode in the attached pane directly from vim (solves partially #70)

christoomey commented 6 years ago

Hi @giovannibenussi, good question!

Unfortunately the current version of the plugin does not support sending SIGINT (I'm treating this as equivalent to sending the raw key sequence C-c as I don't know of a way to directly send a signal to tmux pane).

That said, I've wanted behavior like this and similar before, so I pulled together a quick branch to test out a new API. You can check out the branch here: https://github.com/christoomey/vim-tmux-runner/tree/cjt-add-send-raw-command. It introduces two new commands:

Would you mind trying out this branch to see if this works for you? Assuming it works, I'll update the documentation and merge this in.

Thanks!

giovannibenussi commented 6 years ago

Hi @christoomey, thanks for your fast answer and solution! I just try the VtrSendKeysRaw command and it works as expected using ^C and ^D as parameters. The VtrSendCtrlC also works as expected!

I don't really understand what do you mean with the mapping for VtrSendKeysRaw with ^C. However, I add this to my .vimrc to map <leader>c to send VtrSendKeysRaw ^C to the attached pane:

nnoremap <leader>c :VtrSendKeysRaw ^C<cr>

I try that and it works as expected! That was what you mean?

Regards!

christoomey commented 6 years ago

I was trying various version of <C-c> and using ^V^C to get a literal ^C, which didn't work, but ^C as the distinct characters works! How nice! I'd prefer to not have to special case it, although I'll likely want to document this mapping so folks won't hit the issue I did.

I'm going to keep this issue open until I merge in the final version, but hopefully the branch is enough to keep you going in the mean time. Thanks!

giovannibenussi commented 6 years ago

That's very nice, I like that mapping! This will make my work with vim and tmux easier!

Thanks a lot @christoomey! :)

mbrinkme commented 6 years ago

Thanks @christoomey! It's very well and improves my workflow!

tmm commented 4 years ago

@christoomey love this! need any help getting the branch across the finish line?

Edit: Created PR #98 updating the documentation. Would love to see this merged!