2

When I'm in a multi-pane tmux window, on the leftmost pane, pressing my shortcut to move to the pane to the left will cyclically move the focus to the rightmost pane. I would prefer this shortcut to take no action in this case, i.e., to stay in the already selected leftmost pane.

I read the man page. There is also a chapter about pane traversal in the The Tao of Tmux book, but this is not mentioned.

The select-pane command in tmux has a lot of switches, but they are not documented:

$ tmux select-pane --help
usage: select-pane [-DdegLlMmRU] [-P style] [-T title] [-t target-pane]

In case it's relevant, my shortcuts to select the panes are as follows:

bind -n C-M-h select-pane -L
bind -n C-M-j select-pane -D
bind -n C-M-k select-pane -U
bind -n C-M-l select-pane -R
0

It's quite easy with pane_at_left, pane_at_right, pane_at_top and pane_at_bottom formats.

bind -n C-M-h if-shell -bF '#{pane_at_left}'   '' 'select-pane -L'
bind -n C-M-j if-shell -bF '#{pane_at_bottom}' '' 'select-pane -D'
bind -n C-M-k if-shell -bF '#{pane_at_top}'    '' 'select-pane -U'
bind -n C-M-l if-shell -bF '#{pane_at_right}'  '' 'select-pane -R'

These formats were introduced in tmux 2.6. In prior versions you can still get the same effect by running scripts (run-shell) that retrieve window_width, window_height, pane_left, pane_right, pane_top and pane_bottom from tmux (tmux display -p …), perform calculations and comparison, and decide to cast tmux select-pane … or not.

Compare this answer of mine. The script there could use the new formats in few places. I needed the other values anyway, so I decided to keep the script compatible with older tmux.

| improve this answer | |

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.