22

If I have a tmux session called "Test", and inside "Test" I have two windows "Test1" and "Test2", how do I send a command to "Test2"?

tmux send-keys -t Test.Test2 "STUFF HERE" won't work. That syntax is for panes only.

1 Answer 1

56

Unbelievable. I searched everywhere for an answer on the web and I could not find it. Apparently it is just:

tmux send-keys -t Test:Test1 "TEST" C-m

4
  • 1
    How would one accomplish this for a specific pane? May 31, 2020 at 17:12
  • 6
    The syntax for a specific pane is tmux send-keys -t {session}:{window}.{pane}, so tmux send-keys -t Test:Test1.1 "TEST" C-m would send that to the first pane. Jul 9, 2020 at 4:48
  • 2
    You can also specify tmux send-keys -t ':.!' to mean "last active session (i.e. the current one), last active window, previously selected pane." Nov 1, 2022 at 22:05
  • you can find out the target pane's pane ID by executing echo $TMUX_PANE inside the target pane. This will output e.g. %1. With information, you can send keys from anywhere (not necessarily from within tmux) with e.g the following command: tmux send-keys -t %1 "whoami" C-m
    – Abdull
    May 18 at 18:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.