Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Alt-left/right to switch between windows in tmux

I am trying to configure tmux to switch between windows using alt-left, alt-right sequences. This is what I have in my .tmux.conf

bind-key -n M-Left previous-window
bind-key -n M-Right next-window

Unfortunately, it doesn't work. On my machine, alt-left and alt-right are bound to ^[[1;3D and ^[[1;3C respectively. I think I have to use terminfo override to tell tmux to use these sequences, but I have no idea how. So, any help will be appreciated.

Thanks!

like image 886
Alexander Sandler Avatar asked Aug 07 '13 16:08

Alexander Sandler


1 Answers

If the xterm-keys option was off, tmux would ignore the keys (because it would recognize them and discard them when the option was not set). Users of tmux have been confused by this distinction for a while, and at the end of 2016, the developer changed the default for the option:

Change the xterm-keys option to default to on, so that tmux will generate xterm(1) escape sequences for function keys with modifiers.

With the option off most of these keys are ignored by default, except
for ctrl + arrows which use a variant that nothing else seems to use and
I don't remember why we chose. The xterm escape sequences are now the
most common.

This still relies upon the terminal description, as I pointed out in tmux on remote machine not getting correct prefix + arrow keys

like image 65
Thomas Dickey Avatar answered Nov 09 '22 14:11

Thomas Dickey