注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

osdba的博客

敢于担当,拥抱变化,锐意进取,永不止步

 
 
 

日志

 
 

How do I bind the tmux prefix key to C-'?  

2012-09-23 19:35:21|  分类: linux |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

http://superuser.com/questions/395233/how-do-i-bind-the-tmux-prefix-key-to-c

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?

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

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 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 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 at 18:48


  评论这张
 
阅读(527)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017