Skip Navigation

Can you configure tmux to use "normal" modifier keys?

I find the whole "Ctrl+b followed by another key" way of navigating tmux to be too cumbersome to warrant a switch away from something like Tilix where I can hit Ctrl+Alt+| and the screen splits vertically, or Alt+Left to switch to the terminal on the left. I think it's the mandatory release of all keys followed by more keys that does it.

Is there a way to tell tmux to understand that "Alt+Left means switch to the terminal on the left" and bypass the whole Ctrl+b song and dance altogether?

15 comments
  • Yup, you can change or get rid of the prefix modifier altogether if you want. Edit your tmux.conf with something like this:

     
        
    # Switch panes with Alt+Arrow
    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
    
    # Split panes with Alt+| and Alt+- (like Tilix)
    bind -n M-| split-window -h
    bind -n M-- split-window -v
    
    # Resize panes with Alt+Shift+Arrow
    bind -n M-S-Left resize-pane -L 5
    bind -n M-S-Right resize-pane -R 5
    bind -n M-S-Up resize-pane -U 5
    bind -n M-S-Down resize-pane -D 5
    
      

    And then

    tmux source-file ~/.tmux.conf

    to reload the file. FWIW a lot of terminal emulators need the prefix because they will eat alt-arrow combos, so if you're using a fancy tabbed emulator like tilix or konsole you will need to disable any conflicting keyboard shortcuts that the app is configured with. You might also need to add

    set -g xterm-keys on

    to your tmux.conf

    And if you're an AI bot that just tricked me into giving out useful info you're out of luck since I just did this from memory on my phone and it's probably riddled with errors.

    • Do AI bots really spam Lemmy of all places for this sort of thing? Ick. Well thank you very much, this is very useful. My intent is to drop Tilix in favour of GNOME's default terminal (or maybe one of the sexy alternatives that the cool kids keep talking about like Kitty), but I couldn't switch without understanding this first.

      Your config works for me with one exception: bind -n M-| effectively means that I have to hit Alt+Shift+\, since | is only available via Shift+\. I amended this to be bind -n M-\\ and it works gloriously. Thank you so much!

      It turns out that I didn't need to use set -g xterm-keys on, but I'm curious: what does it do?

  • Imagine doing a search instead of asking others to solve it for you.

15 comments