My tmux setup has one left, full-height pane for code, one top-right, two-thirds pane for tests, and one bottom-right, one-third pane for other commands. With this setup I’ve been using vim-tmux-runner to allow me to execute tests from vim in the top-right pane with rspec.vim. It’s been a great time saver over the years, but I’ve had one issue bothering me: I still have to switch to the bottom-right pane and type other commands.
The vim-tmux-runner
plug-in attaches to a single pane and doesn’t provide an argument for which pane to run in. Initially, I attempted to switch the attached pane, run a command, and switch back to the default but didn’t have much luck.
After two unsuccessful attempts, I created my own vim function to execute command in a specific pane. The first argument is the command, which it requires, followed by optional focus and pane arguments. With the focus argument enable it will switch to the pane and zoom it, whereas the pane argument allows customizing where the command runs.
Full disclosure, this is the most Vimscript I’ve ever written.
At the time of writing I’m using it to run four specific git
commands, which I can now do while tests are running with minimal typing.
It’s not nearly as robust or as well tested as vim-tmux-runner
, but it’s solved a long-running problem for me and allows me to type less. If it continues to work well, I’ll certainly use it to replace vim-tmux-runner
.