65

I'd like to switch directly to a pane in Tmux, by pane #.

How can I do this? I know how to cycle between panes, and move to panes that are beside the current pane.

I'd like to be able to run the display-panes command, which shows the "pane #" on each pane, then later on jump directly to a pane using the pane #'s that were displayed by display-panes.

Is this possible?

NOTE: And just to be clear, I don't mean window, I mean pane. Thanks!

Brad Parks
  • 1,669
  • is there any way to focus the currently highlighted pane using the direction keys to navigate panes? eg I up arrow to be sent to bash and not tmux after the current pane is selected... the timeout drives me crazy – ThorSummoner Oct 12 '19 at 20:53
  • none that I know of – Brad Parks Oct 13 '19 at 13:09

4 Answers4

84

You can jump directly to a pane by typing pane's index while it is showed by display-panes command.

From man tmux:

display-panes [-t target-client]
                   (alias: displayp)
             Display a visible indicator of each pane shown by target-client.
             See the display-panes-time, display-panes-colour, and
             display-panes-active-colour session options.  While the indicator
             is on screen, a pane may be selected with the ‘0’ to ‘9’ keys.

Or instead of typing command, you can use:

C-b q
  • C-b send prefix key
  • q display panes indexes
cuonglm
  • 153,898
  • 17
    If the pane #'s show too quick for you to select a pane, use the following in your .tmux.conf file to change the amount of time the pane #'s are displayed. set display-panes-time 4000 Note that you can hit the esc key to cancel the operation if you want – Brad Parks Sep 18 '14 at 12:37
  • Can you also so up and down, right and left instead of using a number? – khatchad Apr 20 '17 at 15:14
  • The set display-panes-time 4000 works nicely, however, there is one edge case I hit that is just a minor thing but would be good to know how to get around it. If I have my default shell set to tmux and use guake to launch into it, the first time I get an /home/elynn/.tmux.conf:92: no current session warning. – Elijah Lynn Jun 27 '18 at 21:37
  • 1
    K, looks like -g works, set -g display-panes-time 4000 – Elijah Lynn Jun 27 '18 at 21:42
  • Furthermore if you open more than 10 tmux panes, it is not easy or impossible to move a specific pane using C-b <pane #> when the pane index is larger than 10. In that case, C-b <arrow keys> would be useful to navigate panes and move the focus around panes. – W.Lee Feb 08 '21 at 07:33
32

Ctrlbq (the tmux default prefix sequence plus q) will briefly display the pane indexes, if you enter the index number while they are displayed, your cursor will move to that pane.

If you have a large number of panes and the display time is too short, you can configure tmux to display the index for a specified interval with the display-panes-time option in your ~/.tmux.conf. The value is in milliseconds.

jasonwryan
  • 73,126
12

When you know the indicator of your target-pane (e.g. by display-panes), you can directly switch to this pane with select-pane.

From man tmux:

select-pane [-DdegLlMmRU] [-P style] [-T title] [-t target-pane]
                   (alias: selectp)
             Make pane target-pane the active pane in window target-window,
             or set its style (with -P).

Say you want to switch to the pane with the indicator 2, type:

C-b : select-pane -t 2

or the alias

C-b : selectp -t 2
8

I know this isn't necessarily what you asked for, but enabling mouse support is pretty easy and most terminal emulators support it.

You may simply click on the pane you want to switch to. :)

Steven Lu
  • 2,282