Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Split pane switching in tmux: switch once per command

Tags:

tmux

I've been a happy tmux user for a while now but there's one behaviour that's bugging me. When I switch panes using ^b-arrow, and then immediately press arrow-up (to get a command from history, for example), the window pane switches again. I understand this can be useful if you want to move through multiple panes quickly, but for me it's a pain in the backside since I keep ending up in panes I never meant to be in.

So, is there a way to set tmux so that the ^b-arrow command only switches pane once and ignores any following arrow key presses?

like image 615
SteakTartaar Avatar asked Dec 02 '12 11:12

SteakTartaar


People also ask

How do you rearrange panes in tmux?

To change the layout of panes in a Tmux windows, press <prefix><space> . It will change between different layouts. We may also use command select-layout (or selectl for short) instead.

What is Ctrl-B in tmux?

ctrl-b, <arrow key> switch to the pane in whichever direction you press. ctrl-b, d. detach from tmux, leaving everything running in the background.

How do I close split pane tmux?

To close a pane, first ensure that you're positioned in it. Then type "exit" or Ctrl-d. Note that there is no need for Ctrl-b in this step. Once you type "exit" or Ctrl-d in the last remaining pane, tmux will close.


2 Answers

That happens because the default bindings for the arrow keys are setup with bind-key -r, specifying that they may be repeated. There are two ways that you can disable this.

First, you can use set-option repeat-time 0 to disable repeating entirely. This will affect all bindings. I find that to be very annoying when resizing panes.

Secondly, you can change the bindings for the arrow keys to use bind-key without the -r option:

bind-key Up    select-pane -U bind-key Down  select-pane -D bind-key Left  select-pane -L bind-key Right select-pane -R 
like image 137
qqx Avatar answered Sep 23 '22 15:09

qqx


If you spend a lot of times navigating panes, why not set up global mappings so you don't have to use prefixes at all, e.g. bind -n C-h select-pane -L to map ctrl-h to switching left, same as Vim.

See http://robots.thoughtbot.com/seamlessly-navigate-vim-and-tmux-splits for an even better solution that also navigates across Vim windows.

like image 35
mahemoff Avatar answered Sep 23 '22 15:09

mahemoff