Search code examples
linuxterminaltmux

How to switch to the previous pane by any shortcut in tmux?


For example, I have three panes in a window with tmux. Now my cursor is in the second pane. If I use:

C-b o

I can move to the third pane.

But I want to move to the first pane on the second pane. How to do?

It can list all the panes in one window:

C-b q

It will show: 0, 1, 2

Is there any key I can press to go to the special pane number? If there is, I can switch to the first pane in a short way, too.


Solution

  • In tmux manual ($man tmux) you can find this section:

    select-pane [-DdeLlRU] [-t target-pane]
        (alias: selectp)
    
        Make pane target-pane the active pane in window target-window.   
        If one of -D, -L, -R, or -U is used, respectively the pane below,
        to the left, to the right, or above the target pane is used.  -l
        is the same as using the last-pane command.  -e enables or -d
        disables input to the pane.
    

    So, I think what you want is to use the '-l' flag, which is for switch to last pane. I don't know if there is a default key mapping defined to this task, but you can accomplish this by doing your own bindings. Something like this:

    bind -r <your key> select-pane -l