i have the following code in my tmux.conf, which copies the selection in copy-mode and sends it to another pane where i have vim opened.
bind-key -t vi-copy o copy-selection
bind-key -t vi-copy o copy-pipe "xclip -sel clip -i"
bind-key -t vi-copy o copy-pipe "xargs -I{} tmux send-keys -t 1 ';call OpenTestFile(\"{}\")' Enter && tmux select-pane -t 1"
I think, the xargs -I{} command triggers, that every line of the selection is send to that pane one by one. So if i select 6 lines, tmux will send these 6 lines to the pane with vim in it.
But i only want to have one call of send-keys with the whole selected string send to the pane.
So, is there another tool, that reads the standard input and sends it to tmux send-keys or can i modify the xargs -I{} part, that it executes only once with all the selected lines?
There's a -J flag that is similar to -I, but it doesn't split the input. It's pretty much, exactly what you want except -J doesn't work with quoted strings.
So after some poking around, There's an -L flag that tells xargs how many non-empty lines to read. If you set -L to a number higher than the arguments you're sending, they should all be sent at once, e.g.
bind-key -t vi-copy o copy-pipe "xargs -I{} -L 10000 tmux send-keys -t 1 ';call OpenTestFile(\"{}\")' Enter && tmux select-pane -t 1"
I suspect this will break if one of your selections is an empty line.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With