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

1

8

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!

Bandler answered 7/8, 2013 at 16:49 Comment(4)
tmux should recognize those sequences automatically, no matter what TERM you use externally (and also regardless of what the corresponding terminfo entry says). Did you restart your tmux server after putting those entries in your config file? If all of the commands are idempotent, you can source ~/.tmux.conf in your existing server to pick up the changes.Monster
@ChrisJohnsen I am absolutely certain that tmux picked the configuration.Bandler
Did you ever find an answer to this? I'm having the same problem with Ubuntu 12.04, terminator 0.96, and tmux 1.9a.Mordred
I just tried this in Ubuntu 16.04 and it works for me.Agency
L
1

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

Lingua answered 19/2, 2017 at 19:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.