Terminal: Tmux: Custom config - Alt/Meta+(arrow key) for switching between panes doesn't work

Created on 1 Mar 2020  路  5Comments  路  Source: microsoft/terminal

Environment

Windows build number: 10.0.18363.0
Windows Terminal version (if applicable): 0.9.433.0

Any other software?
WSL - Ubuntu 18.04

Steps to reproduce

I have a custom tmux config, where I defined Meta+arrows to switch between panes. The shortcuts work just fine when using the default terminal, however, with the Windows Terminal, the shortcut does not work in either WSL or when SSHed into a physical Ubuntu workstation.

Expected behavior

Add the following to your tmux.conf and use Alt+arrow to switch between panes (without, the prefix combination).

# switch panes using Alt-arrow without prefix
bind -n M-Left  select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up    select-pane -U
bind -n M-Down  select-pane -D

Actual behavior

The shortcut keys work while using the default (old) terminal, but do not work while WSL is using the new Windows Terminal.

Is this a key combination clash between some existing functionality? (I also found this issue #4460).

Area-Settings Issue-Question Needs-Triage Product-Terminal Resolution-Answered

Most helpful comment

This is because those keys are actually bound by the Terminal by default to move focus within the _Terminal_'s panes 馃槄 See their definition in the defaults here:

https://github.com/microsoft/terminal/blob/4608fd0b94af2f4cf6ceec7b324ba36462e9c06b/src/cascadia/TerminalApp/defaults.json#L215-L218

If you want to unbind them, so that tmux can use those keys, you can add the following to your profiles.json

 { "command": "unbound", "keys": "alt+down" }, 
 { "command": "unbound", "keys": "alt+left" }, 
 { "command": "unbound", "keys": "alt+right" }, 
 { "command": "unbound", "keys": "alt+up" }, 

(alternatively, you could bind the moveFocus to another set of keys.)

All 5 comments

This is because those keys are actually bound by the Terminal by default to move focus within the _Terminal_'s panes 馃槄 See their definition in the defaults here:

https://github.com/microsoft/terminal/blob/4608fd0b94af2f4cf6ceec7b324ba36462e9c06b/src/cascadia/TerminalApp/defaults.json#L215-L218

If you want to unbind them, so that tmux can use those keys, you can add the following to your profiles.json

 { "command": "unbound", "keys": "alt+down" }, 
 { "command": "unbound", "keys": "alt+left" }, 
 { "command": "unbound", "keys": "alt+right" }, 
 { "command": "unbound", "keys": "alt+up" }, 

(alternatively, you could bind the moveFocus to another set of keys.)

@atifraza Did this fix your problem? I have the same issue and @zadjii-msft's fix didn't work for me.

We may have broken key _unbinding_; #3729

Oh beans! For what it's worth I've also tried { "command": null, "keys": "alt+down" } and got the same result.

Thanks for all your hard work!

@tjhowse I tried the key unbindings but that did not work. Since it was something new I was trying for tmux shortcut keys, I did not pursue it further.

Was this page helpful?
0 / 5 - 0 ratings