Warning The software in this article is highly outdated, unsupported, and I have no idea if it still works with the current iTerm or if it’s even useful anymore.
iTerm’s key mapping system allows for a number of possible “actions”:
“send escape sequence” simply sends a “\e” followed by the text as-is;
“send hex code” scans for one 8-bit code, and sends that;
“send text” allows for “\e” (escape), “\n” (newline), “\a” (bell), and “\t” (tab), and normal text.
The goal of this small patch is to add two escape sequences to the “send text” action:
“\\” to send a single backslash;
“\xAA” or “\xBBBB” to send an arbitrary unicode character specified in hexadecimal.
For example, to bind the conventional “backward-kill-word” to option-delete (or alt-delete or meta-delete, or “backspace” on PC keyboards), you can simply add a key mapping for “delete”, checking “option”, selecting “send text” as the action, and typing, in the text box, “\e\x7f”.
From then on, hitting option-delete will delete the word on the left of the cursor :)
Patching and compiling iTerm
First, go to the iTerm’s develop page and follow the instruction to obtain the source code. Essentially this corresponds to this:
$ cd ~/Desktop $ mkdir iTerm $ cd iTerm $ svn co https://iterm.svn.sourceforge.net/svnroot/iterm/trunk iterm
Then, download the patch below, and…
$ cd iterm $ patch < somewhere/iTerm_send_text_extended-02_trunk-1878.diff
Then you need to compile iTerm in Xcode using the “Deployment” active configuration, then, in the shell:
$ mv /Applications/iTerm.app /Applications/iTermOriginal.app $ cp -aL build/Deployment/iTerm.app /Applications/
Et voilà! Just launch iTerm, and add a few \xXX key bindings!