Sunday, July 23, 2006

Bash + Readline + Sanity

So yesterday, in a futile attempt to convince Firefox, X.org, Ubuntu, and a really large s5 presentation to work together without consuming ridiculous amounts of CPU I upgraded from Ubuntu Breezy to Ubuntu Dapper.

Naturally, tihs didn't actually fix anything of consequence, although it did give me a laptop that boots quite a bit faster (bonus!), and an X screen resolution control panel that is capable of controlling the resolution on more than one display (kind of slick).

Unfortunately, it broke my .inputrc, which sets up and down arrows to history-search-backward and hisory-search-forward respectively, and since I'm totally addicted to that feature I had to stop all productive work and find a way to fix it.

After flailing around hopelessly for a while, I came upon the /usr/share/doc/bash/inputrc.arrows file, which has various different ways to configure your arrow keys. Now just cut and pasting all of them into .inputrc didn't help much, well it did actually fix the problem I was working on, but it made me have to hit enter twice to do anything, which isn't really a step forward in my opinion. But after paring it down to just the basics, I found that the following worked:

set enable-keypad on
"\C-[OD" backward-char
"\C-[OC" forward-char
"\C-[OA" history-search-backward
"\C-[OB" history-search-forward

Previously I had gotten away with:

"\M-[A": history-search-backward
"\M-[B": history-search-forward
"\M-[C": forward-char
"\M-[D": backward-char

This worked on dozens of systems, and I still have no idea why it stopped working, but whatever...

Just figured I'd post it in case anyone else has the same problem, or, more likely, I have the same problem again and need to look up what I did to fix it ;-)

4 comments:

  1. I got this letter from Volvo with a really great deal but I have to act fast. Can I trade in your car?

    ReplyDelete
  2. I had a possibly-similar problem with my "\M-" readline key bindings. (IIRC, my probem only occured in X terminal emulators, not on the Linux console.) I ultimately tracked it down to an encoding issue: if the xterm's LC_CTYPE was 'en_US.UTF-8' my binding didn't work. My "fix" was to use ISO-8859-1, but now I'll have to see if there's an alternate encoding for the key name which will let it work with UTF-8.

    ReplyDelete
  3. Thanks. This posting helped me a lot.

    ReplyDelete
  4. "...and an X screen resolution control panel that is capable of controlling the resolution on more than one display (kind of slick)."
    LOL. Welcome to 1986.

    ReplyDelete