2

Many of the commands in tmux deal with a target and source window/pane and I know sometimes you can supply things like 1:2 to specify pane 2 of window 1, however now I'm looking at more advanced usage, sessions now seem to fit in to this aswell.

I constantly forget the syntax and I can't find detailed information about it in the documentation.

Could anyone help shed some light?

5

your answer is hidden in an example inside a text about target-pane :

target-pane (or src-pane or dst-pane) may be a pane ID or takes a similar form to target-window but with the optional addition of a period followed by a pane index or pane ID, for example: ‘mysession:mywindow.1’. If the pane index is omitted, the currently active pane in the specified window is used. The following special tokens are available for the pane index:

You can test it by creating a background/daemonized tmux session named $SESSION like so :

tmux new-session -d -s $SESSION

you can monitor this session in another terminal by using :

tmux attach-session -t $SESSION

and then using this command from the "non tmux" terminal

tmux send-keys -t $SESSION:0.42

and then if the pane 42 doesnt exist, tmux will complain.

Now by using a test string, like so :

tmux send-keys -t $SESSION:0.42 "test" C-m

You can pinpoint the exact pane interactively if you don't know the exact pane number that you want.

On a side note, you can display pane numbers inside a tmux session by entering (listed in the key bindings session of the documentation you linked)

    C-b q           Briefly display pane indexes.
2
  • So when the OP says "1:2 to specify pane 2 of window 1", it's a misunderstanding, because 1:2 specifies window 2 of session 1. Pane 2 of window 1 (of current session) would be :1.2. Right? – Kamil Maciorowski Dec 28 '17 at 13:23
  • It looks like so, i can't confirm right now that the "current session" is implied by not using anything before :1.2, but if you take the good habit of giving all your sessions a name it definitely works as expected (and protects bad interactions between scripts that run tmux non-interactively, or at least unattended) – poncet_f Dec 29 '17 at 15:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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