Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 5 down vote accepted

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).

share|improve this answer
    
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... –  Jeffrey Yasskin Mar 18 '12 at 9:13
    
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 –  Chris Johnsen Mar 18 '12 at 10:43
    
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. –  Jeffrey Yasskin Mar 18 '12 at 18:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.