Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable pane switching with ESC in Tmux

I noticed that esc will also start listening for instructions to switch panes. I'm new to Tmux, I copied a Tmux conf file earlier today which should only have enabled alt to switch panes, so I'm not sure if this conf file enabled it or if it's standard in Tmux 2.3.

Seeing as I tend to start moving around after entering normal mode, this annoys the hell out of me. Can anyone tell me how to disable pane switching with esc?

like image 368
Tijsdv Avatar asked Mar 24 '17 21:03

Tijsdv


2 Answers

Found this, which fixed the problem for me: https://unix.stackexchange.com/questions/23138/esc-key-causes-a-small-delay-in-terminal-due-to-its-alt-behavior

Add to your ~/.tmux.conf:

set -s escape-time 0
like image 142
ipetrik Avatar answered Nov 05 '22 04:11

ipetrik


I think your ~/.tmux.conf file contains lines like below:

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

These lines bind Alt-h(j,k,l) to switch pane without need of prefix key. But it seems that ESC+h(j,k,l) will also trigger the Alt-h(j,k,l). I don't know why either.

My way to fix it:

  1. Make sure you have closed the tmux session. ( use "prefix+&+y" to kill all window)
  2. Change the key binding above in .tmux.conf to the new one below:

    bind -n C-j select-pane -D \; display-panes

    bind -n C-k select-pane -U \; display-panes

    bind -n C-h select-pane -L \; display-panes

    bind -n C-l select-pane -R \; display-panes

  3. Restart your tmux. This will remove your previous M-(h,j,k,l) binding, and the new binding will take effect.

    The meaning of the new binding is to: Use Ctrl-vim keys without prefix key to switch pane, and at the same time, show the pane indicator: the current active pane index's color will be red.

like image 33
Jinliang Wang Avatar answered Nov 05 '22 04:11

Jinliang Wang