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 have set up a few custom keyboard shortcuts in iTerm2 to easily move the cursor around with the arrow keys, but now I'd like to remap Ctrl+E to be Esc, Ctrl+E because Bash 4.2 no longer auto-expands variables using the Tab key.

I know I've done the first part correctly in choosing the keyboard shortcut to remap, but I don't understand how to look up the correct escape sequence (or hex codes) to send in the bottom section:

Picture.png

I reference they keyboard codes but that wasn't much help.

How can I remap this, and how can I look up the codes in the future? (No luck with Google)

Update

@db - thanks. To save others trouble I also found a cool util Key Codes.app which can be used to find key codes:

Picture.png

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Use the following: Send Hex Codes: 0x1B 0x05

  • Escape is ASCII 27 (it's often written as octal \033 if your shell doesn't know \e).

  • Ctrl-[Character] combinations result in the ASCII code corresponding to the character's position in the alphabet. Well-known examples are^H for ASCII 8 (Backspace), ^C for ASCII 3, End of Text, or ^D for ASCII 4, End of Transmission, and likewise, pressing ^E results in ASCII 5 — so that hex code needs to be sent instead.

You can even use this (I cannot imagine a real use case, but let's not care about that) to replace pressing Enter (Line Feed) by ^J, or pressing Tab by ^I. See here for more information about control characters.

share|improve this answer
    
thanks very much - this was bugging me –  cwd Jul 5 '12 at 18:30
    
@Daniel: can you take a look at superuser.com/questions/731427/how-do-i-send-ctrl-in-iterm2 ? –  eugene Mar 20 at 14:59

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.