I have various tooling around tmux and history so I can trace back what happened where (in which pane, in particular).

inside my zsh preexec I am able to log out (for my custom shell command history format) various pieces of information that I associate with the commands I run:

  • $TTY will show me e.g. /dev/pts/34
  • $(tmux display -p "#{window_id} #D") provides me with e.g. @4 %28

Even if I only have the $TTY, I can use the output of

tmux list-panes -a -F '#{pane_tty} #{window_id} #D'

to map it.

Now I just wanted this workflow: I'm looking at my custom history log and I am able to obtain @4 %28 but it seems like I have to issue two tmux calls to actually focus the pane in question. I have to run

tmux select-window -t @4 && tmux select-pane -t %28

Just wondering if theres a more straightforward way. tmux select-pane -t @4 %28, or, really, the select-pane probably should just focus the window for me?


I'm generally satisfied with the simplicity of the tmux cli interface... what select-pane will do is simply select that pane, and leave the window and session state alone.

In my question I failed to consider the implications of trying to "navigate" to a specific pane if I happen to be attached to a different session. The cli will allow me to mutate the current window and current panes of any session at will, as well as switch to any session. We just don't have a friendly interface for doing all of that in a painless way. (an example of how it isnt painless is that session id's look like $2 so you have to specify these in single-quotes)

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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