christoomey / vim-tmux-runner

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

Use VtrClearSequence to clear buffer history #106

Open AlexChalk opened 3 years ago

AlexChalk commented 3 years ago

Hi,

I'm trying to use the VtrClearSequence value to issue a tmux clear-history command to my attached pane before sending a command, and it seems like a reasonable use case for a clear command. I want to be able to e.g. run tests and search my buffer for errors without finding results from my previous test run.

I checked the source code, and it seems like the clear sequence is used something like this: !tmux send-keys -t ~pane#~ ~clear-sequence~ ~main-command~. The problem is that executing clear-history like this, e.g. !tmux send-keys -t 1 "tmux clear-history" Enter, well, doesn't clear the history of the pane!

I guess there's something going on with how this command is executed that I don't understand; maybe clear-history doesn't understand the context in which it's been executed when it's run via send-keys? Do you have any ideas about what might be going on?

Thanks for any help you can provide!

christoomey commented 3 years ago

Hmm, the use case you're describing isn't exactly supported by the current commands, unfortunately. VtrClearSequence is intended to be a key sequence, e.g. Ctrl-l that can be sent to the shell session within a tmux pane, rather than tmux itself. clear-history is a tmux command, so they're operating at a different level.

To support your use case, I think we'd need to add a new VtrClearRunnerHistory command which under the hood executes tmux clear-history -t <runner-pane>. I'd welcome a PR that implements that if you're interested in poking around, but likely won't have time to tackle in the near term.

Hope that helps, or at least clarifies!

AlexChalk commented 3 years ago

It does, thanks! I'll see how busy I am ;)