How can I set tmux hotkey as Ctrl-, that is, Ctrl+comma

寵の児 提交于 2020-08-21 05:29:57

问题


I've got some trouble when setting my preferred tmux hotkey on Mac OS X.

The most common hotkeys that invokes tmux's magics are CTRL+A and CTRL+B. But I would rather select other keystrokes for the following reasons: C-a is the global hot key for "jumping to the beginning of a line"; C-b is for "moving backward on a line" and "Page UP in Vim". I don't want to break these nice rules in tmux.

So, I try to set some non-so-frequently-used keystrokes for tmux hotkey. What I choose is CTRL-, , CTRL-., or CTRL-;

I write this statement in my .tmux.conf file:

set-option -g prefix C-,

I start tmux. Oh, it says "bad key". I replace C-, with C-. or C-;. It doesn't work either.

So, how can I set tmux hotkey to CTRL-,?


回答1:


Had to dig into the source code for this one. The control key can only be applied to letters, @, space and ? (and C-@ seems to be equivalent to C-space). Sorry, doesn't look like C-, is possible, at least in tmux-1.6.




回答2:


None of comma, period, or semicolon are standard control characters. Your terminal emulator probably just sends the plain character, or nothing at all when you type them; you can type them at into cat -v to see what it is sending.

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

If you can reconfigure your terminal emulator to send some other character/sequence, you should be able to use it in tmux (e.g. have your terminal emulator send the same character as C-\ (hex 1C), and set your prefix to that).




回答3:


Using xterm terminal

1) put these in your ~/.Xresources to generate escape sequence of F13 when CTRL-,, CTRL-. or CTRL-; is pressed

XTerm.VT100.translations: #override \                                                                                                   
    Ctrl<Key>period:    string(0x1b) string("[1;2P") \n\                                                                                
    Ctrl<Key>comma:    string(0x1b) string("[1;2P") \n\                                                                                 
    Ctrl<Key>semicolon:    string(0x1b) string("[1;2P")

run xrdb ~/.Xresources to load these conf.

2) change prefix in your ~/.tmux.conf

set -g prefix F13

3) fire xterm and tmux

$ tmux


来源:https://stackoverflow.com/questions/9922497/how-can-i-set-tmux-hotkey-as-ctrl-that-is-ctrlcomma

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!