brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: set -s extended-keys on passes keys like Ctrl-Shift-a to programs in tmux

Tmux
~/tips/tip-tmux-extended-keys

set -s extended-keys on

Lets programs inside tmux tell apart key combinations that normally arrive as the same code.

In a classic terminal, Tab and Ctrl-i send the same byte, and Ctrl-Shift-a looks exactly like Ctrl-a. Newer terminals can send richer codes for those keys, and an editor can map them to different things. Inside tmux that only works when you let it.

set -s extended-keys on
set -as terminal-features 'xterm*:extkeys'

The first line is a server option. With on, a program in a pane can ask tmux for extended keys, in mode 1 (only keys that have no normal code) or mode 2 (all keys). tmux already asks the outer terminal for extended keys itself when it can. The second line tells tmux your terminal supports them, for when it does not detect that on its own.

You can see whether a pane asked for it. This prints VT10x for a normal pane:

tmux display -p '#{pane_key_mode}'

After a program sends the request, for example printf '\033[>4;1m' in that pane, it says Ext 1. With extended-keys off the request is ignored and it stays VT10x. The format of the codes is set by extended-keys-format: xterm (the default) or csi-u.

I’d turn this on when you use Neovim or another editor that maps keys like Ctrl-Shift combinations, and leave it alone otherwise.

All three parts have to be there: the terminal must support it, tmux must have it on, and the program must ask. The tmux wiki names xterm, mintty and iTerm2 as terminals that support it, and iTerm2 needs a setting in the profile. tmux supports extended keys since version 3.2. If a key still does nothing, press Ctrl-V and then the key in your shell to see what really arrives.

Further reading: tmux manual page (OpenBSD), tmux wiki: Modifier Keys

Going deeper: Guide: advanced tmux, a config that grows with you, formats, layouts and more

More Tmux tips set -s history-file ~/.tmux_history tmux list-keys -T prefix ] set -g prefix2 C-a bind S run-shell -b '~/bin/sync-notes.sh' set -g status-justify centre All Tmux tips (133) All topics

Link