Make Terminal.app key mappings work in bash

Aug 06, '04 09:43:00AM

Contributed by: folkert

there is a strange behaviour in [at least my] Terminal.app which prevented me from tuning bash to my preferences for some time now. In Terminal -> Window Settings (i.e. the Terminal Inspector window) -> Keyboard section, the Key Mappings section contained these two entries (among others):

For some reason, the Terminal would not send these keycodes to readline and thus to bash, though. After looking for the mistake in a lot of other places, I just changed the entries in the Terminal Inspector to exactly the same values as they already were, and the desired key mapping worked instantly.

Key mapping is quite useful for utilizing various bash convenience features. For example, to be able to move the cursor in bash one word at a time, first make the changes described above (re-typing exactly what was already there), then add these two lines to your ~/.inputrc file:
"[5D": backward-word
"[5C": forward-word
Since I patched Panther over Jaguar and Jaguar over Puma, this problem could be non-existent on other systems, of course.

[robg adds: I had the exact same issue on my machine, though I had to add the lines to the .inputrc file first -- but even after doing that, the control-left and control-right arrows didn't move a word at a time until I re-typed the key definitions. Odd!]

Comments (9)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20031226130716602