3

Using tmux to send commands along from one terminal to another, I realize that

$ tmux send -t mySession "text" ENTER

correctly sends text, but

$ tmux send -t mySession "up" ENTER

sends text again, probably because up is interpreted not as text, but as keyworded key up arrow.

Similarly,

$ tmux send -t mySession "3" ENTER

correctly sends 3, but

$ tmux send -t mySession "-3" ENTER
tmux: unknown option -- 3
usage: send-keys [-lRM] [-t target-pane] key

fails with this error message, and this naive try to escape

$ tmux send -t mySession "\-3" ENTER

sends 3 again, not the expected -3.

Anyway, I'm pretty sure that I've missed something about the way tmux interprets and understand its argument. What am I missing here?

How do I ensure that mytmuxcommand "<text>" ENTER will always be interpreted as "send actual <text> then send ENTER key"?

1 Answer 1

2

To send a string literally you can use the -l option to send-keys, but as you might still have more options after the -l you need to use something like '' (an empty string) to no longer be looking for options beginning -.

You cannot mix and match the literal with keynames like Enter, so finally you need to give two commands, eg:

tmux send-keys -t session -l '' -3 \; send-keys -t session Enter
1
  • That really is heplful, cheers :) Don't forget to wrap your <text> in quotes because tmux send-keys -t session -l '' two words actually sends twowords, but tmux send-keys -t session -l '' "up down" does send up down as expected :)
    – iago-lito
    Sep 29, 2018 at 8:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .