Sunday, january 24th, 2010

iTerm: extend the “send text” action

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:

1
2
3
4
$ cd ~/Desktop
$ mkdir iTerm
$ cd iTerm
$ svn co https://iterm.svn.sourceforge.net/svnroot/iterm/trunk iterm

Then, download the patch below, and…

1
2
$ 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:

1
2
$ 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!

Posted at 01:30
 
Anglais seulement
Tags: iTerm · osx · terminal

Comments

Comment RSS

There are no comments for this entry.

Drop a comment






Comments are formatted using Markdown. Basic syntax on Wikipedia.