Passing selections to external commands as arguments rather than piping in kakoune

323 views Asked by At

I am trying to send code to SBCL directly from Kakoune. I've settled on using tmux for this, the SBCL instance runs in a tmux instance with a given session name. The tmux command for passing in the key inputs is as follows:

tmux send-keys -t <session-name> "<text to send to tmux>"

In kakoune, however, it seems that the most convenient existing ways to pass selections' text into an external command is through piping, not as an argument. For now this seems to work:

nop %sh{tmux send-keys -t sess -l "$kak_selection"}

This kind of does what I want, but it only sends the primary selection. I cannot really use $kak_selections because this adds single quotes to the selections, which would not be parsed as intended by SBCL. Even if it didn't, I'd prefer if it behaved more like alt+|, which pipes the selections into their own instances of the command. Is there an existing way in Kakoune to do this? If not, would it be easy to write an sh script that would convert the stdin to a quoted argument for tmux?

1

There are 1 answers

0
Charlim On

I was unable to find any built-in way to do this, but this question/answer helped: Piping result of command as an argument

I ended up settling on this command to be run externally (so that I can use the default piping behavior in Kakoune)

xargs -0 tmux send-keys -t sbcl -l "${@}"