5

I'd like to set my tmux prefix key to Ctrl-apostrophe, but when I use set-option prefix "C-'" or set-option prefix C-"'", tmux complains that "unknown key: C-'". Similarly for ` and :. Is there a way to bind these keys?

1 Answer 1

10

Most terminal emulators only generate special output for a restricted set keys when used in combination with the Control modifier key. The apostrophe key is one of the keys that does not generate any special output sequence (it ether does nothing or just outputs a regular apostrophe).

See Wikipedia’s “ASCII control characters” and “How control characters map to keyboards”.

You can check to see if your terminal emulator generates any output for Control-', by typing it into cat -v, or at a shell prompt (in most common shells) after typing a Control-V.

If it does generate some special output (not just '), then you might be able to bind it in tmux if the control code/sequence is known to tmux. The list of keys names that tmux recognizes is in its manpage under the “Key Bindings” section. tmux will only recognize special keys if the terminfo entry for your TERM outside of tmux defines them (see man terminfo for the “capability” names and infocmp for the ones your TERM defines); if needed, you can extend your system’s terminfo entry just for tmux with its terminal-overrides configuration variable (or recompile your own custom entry with tic).

If it does not generate any special output then you would have to somehow reconfigure it to do so (if that is possible); you might have it generate the same code as ^], or the sequence for “F20” (if it is defined in your TERM’s entry when outside tmux).

3
  • I finally got around to switching from gnome-terminal to xterm, so I now know how to remap Ctrl+' (the translations resource). However, by setting the XTerm*modifyOtherKeys:1 resource, I was able to get Ctrl-' to generate "^[[27;5;39~" instead of an apostrophe. Now I wonder if there's a way to get tmux to recognize that, despite it not showing up under infocmp -L xterm-256color... Mar 18, 2012 at 9:13
  • 1
    You can use terminal-overrides to modify bits of the terminfo entry that tmux uses. For example: set -g terminal-overrides "*:kf20=\e[27;5;39~" and set -g prefix F20 Mar 18, 2012 at 10:43
  • 1
    Interesting. I wound up taking your original suggestion. The magic translations string is the following: *VT100*translations: #override \n !Ctrl<Key>apostrophe: string("\033[34;1~"). infocmp reported "key_f20=\E[19;2~", so I had to guess-and-check for the key tmux would recognize. Mar 18, 2012 at 18:48

You must log in to answer this question.

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