Closed laktak closed 4 years ago
There is a command variant, :VtrSendLinesToRunner!
(note the !
at the end of the command) that is intended to provide a smoother workflow in that it will automatically open a runner if you have not yet done so.
That said, it currently hits the same error case if you've closed the pane and run it again. I think it would make sense for it to open a new runner instead of erroring.
I'm not sure when I'll get around to this as I have some more detailed refactoring I'd like to do to the pane attaching functionality (loosely captured in https://github.com/christoomey/vim-tmux-runner/issues/66), but I'll plan to incorporate this when I get around to those changes.
Is there any news on this topic. I really like vim-tmux-runner, but whenever I open up an additional pane manually, or close the runner pane, the system basically dies and I have to restart vim to get back the functionality.
@jerri here's a workaround that I use:
function! SendTmuxCommand(text)
let panes = split(system("tmux list-panes"), '\n')
let active = filter(copy(panes), 'v:val =~ "\\(active\\)"')
let vimPane = str2nr(active[0])
let cmdPane = vimPane + 1
let panes = filter(panes, 'v:val =~ "^'.cmdPane.':.*"')
if len(panes) == 0
call system('tmux split-window -v -l 10')
call system('tmux select-pane -t '.vimPane)
endif
let cmd = "tmux send-keys -t ".cmdPane." ".shellescape(a:text)
call system(cmd)
endfunction
It always sends the command to the pane below the active one or creates a new one.
@Iaktak Thanks for the function! Just a couple of things:
On the third line from the bottom, shouldn't it be let cmd = "tmux send-keys -t ".cmdPane." ".shellescape(a:text) . " C-m"
? Otherwise, it just sends the keys to the new pane instead of running the command.
Also, how might I have it automatically focus on the new pane? Would call system("tmux select-pane -t " . cmdPane)
at the end of the function work?
Here's what I have after changing the above things:
function! SendTmuxCommand(text)
let panes = split(system("tmux list-panes"), '\n')
let active = filter(copy(panes), 'v:val =~ "\\(active\\)"')
let vimPane = str2nr(active[0])
let cmdPane = vimPane + 1
let panes = filter(panes, 'v:val =~ "^'.cmdPane.':.*"')
if len(panes) == 0
call system('tmux split-window -v -l 10')
call system('tmux select-pane -t '.vimPane)
endif
let cmd = "tmux send-keys -t ".cmdPane." ".shellescape(a:text . " && read -s -n 1 -p 'Press any key to continue . . .' && echo && exit") . " C-m"
call system(cmd)
call system("tmux select-pane -t " . cmdPane)
endfunction
Here's what it does:
Thanks again @laktak!
Just ran into the same issue.
Does anyone know if this has been address in the plug-in or are above workarounds still the best way to go?
I have a similar problem as #62 - When I manually close the runner and issue
:VtrSendLinesToRunner
I'd like it to just reopen a new runner instead of complaining withIs that possible?