How can I send Ctrl+; in iterm2 (emacs)?
There seems to be a solution here, here and here
These are close to what I want, but I am still unable to make it work.
The way I make these key combinations work is to go to the Keys
section of the iTerm prefs and create a shortcut for ^;
that sends some escape sequence, like ^[[aa
(you can replace aa
with anything, but be aware that some things are mapped to actual keys). Then in your .emacs
, create a keyboard shortcut for what you want it to map to, like
(global-set-key (kbd "C-[ [ a a") 'the-function-you-want-to-map-to)
^[
(in my example, [aa
). The ^[
(Control-[) control code is "escape".
ESC + [ _your escape sequence_ ]
, indicating that it will actually send an escape key instead of ctrl key. (in my case, ESC seems to map to alt/M-
) Just something weird.
ESC-f
and C-[ f
both do the same thing (and in fact, if you type C-[
, it should show ESC
at the bottom).
emacs -nw
. For me, ESC is definitely the same as pressing alt/option (which I've never consciously changed), although it does show up as for example ESC-f instead of M-f.
How to bind a key sequence to the control key in Iterm2
Download the free application “Key Codes" from the app store. Install it from the link below and then open it.
Hit the Ctrl+some key in this case I’ll use Ctrl+w.
The code in the red square is the code we want to send to the terminal
Now map your key sequence using in iterm, preferences->Keys->+.
The simplest way would be
Preferences
-> Profiles
-> Keys
--> toggle on the Report modifiers using CSI u
.
Here is the documentation of this option and more about CSI u.
There are some detailed discussions in this thread.
0x1B 0x3B
doesn't work?