0

Context

I've been a Linux (power) user for about a year now. I've learned to figure out most things on my own and written many scripts which help me with my workflow. Specifically, I've learned to use an extremely large amount of shortcuts to accomplish frequent tasks. This is where the trouble begins.

Problem

I'd like to be able to switch to the next window in a Tmux session by using 'ctrl+Tab', and switch back to my previous window by using 'ctrl+shift+Tab' without using a prefix (ctrl+b). The bindings I've set in ~/.tmux.conf is

bind-key -n C-Tab next-window
bind-key -n C-S-Tab previous-window

should work as it is the accepted answer to https://stackoverflow.com/a/15471269/5273299. (the difference is my '-n' which has proven to work with the following bindings:

# Remap window navigation to vim-like keys
bind -n C-h select-pane -L
bind -n C-j select-pane -D
bind -n C-k select-pane -U
bind -n C-l select-pane -R

I'm having trouble figuring out where to look. My observation is that tmux does not recognize 'ctrl+shift' as a mapped shortcut. Instead, 'tab' is passed through to vim (when I have VIM opened in that terminal instance), or as 'complete' in my default command-line interpreter Fish.

System

I'm running https://solus-project.com/ as my Linux Distribution -- installed with the Desktop Environment GNOME but installed and using i3-wm as my window manager. My terminal emulator is xrvt-unicode (urxvt). Shell FISH as previously mentioned.

The obvious question would be, does anybody know why ctrl+shift is not being interpreted by tmux? The more general solution would be, does anybody know how I can get a general overview of interpretation levels between all of these shortcut interpreters?

For example:

  • First - keys get sent from the hardware keyboard to the X11 server
  • Then, from X11, if CTRL+Tab is not mapped to anything, it gets sent to i3
  • Then, from i3, if CTRL+Tab is not mapped to anything, it gets sent to urxvt
  • Then, etc.

I'd like to know where the shortcut fails to be interpreted and how I can fix this.

Many thanks in advance!

1 Answer 1

1

It's your terminal emulator which is 'eating' your keys, because there is no known representation/escape for them with which they could be sent to the program running in the terminal.

Shift-Tab is usually mapped to "\e[Z" (kcbt/kB/back-tab key, see terminfo(5)), and that's what tmux is seeing for both Shift-Tab and Control-Shift-Tab; but that doesn't matter anyway, because tmux (apparently) is not able to bind arbitrary key sequences to commands, but only 'standard' keys it knows about.

With that in mind, you could configure urxvt to remap Control-Tab and Control-Shift-Tab to 'Control-b n' and 'Control-b p' (the default keys for next/previous window in tmux)

$ cat | xrdb -override
URxvt.keysym.ISO_Left_Tab: string:\002n
URxvt.keysym.Control-ISO_Left_Tab: string:\002p
! disable the built-in control-shift
URxvt.iso14755:false
^D

"\002" is ^B or Control-b; you should change it if you use another key prefix in tmux (eg "\001" for ^A).

Also notice that on your X server, Shift-Tab may not be mapped to ISO_Left_Tab; use xev(1) to see what keys it's actually sending.

If that works, you could add those lines to ~/.Xresources -- and make sure that file is loaded from the X session scripts (which may not be a given with modern desktops!).

1
  • I'm not using the same system as the one I did at the time of asking this question. Therefore, I won't be able to test your solution. After reading it, it does seem to make a lot of sense. I may try it in the future, and it'll be a good reference for anyone with the same problem nevertheless! Thanks for your research.
    – Edwin
    Oct 9, 2018 at 11:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .