Monday, December 19, 2005

Getting bash key-combinations to work

I'm a really big fan of bash's (readline, actually) ability to have nice command line editing features. One that I use an awful lot is the ability to jump between works using Alt-b and Alt-f.

At this point, it's so hardwired into my brain, that I don't even think about it.

Which is a good thing, unless of course you run into a situtation where Alt-b spits out garbage on your screen instead of going back a word. I can't tell you how frustruating it is to hit Alt-b, notice the garbage and think: "Argh, now I have delete the crap I spit out, and I still have to slowly left-arrow back a few characters. I gotta fix that..." It gets even worse, when you consider I probably do this about 15,000 times a day.

So, I finally found a fix. Put the following in ~/.inputrc:

set meta-flag Off
set convert-meta On
set output-meta Off

Poof, now my Alt-b and Alt-f key works like a champ. Along with their friend, Alt-d, which deletes a word.

So, if you use bash, learn to love Alt-b, Alt-f and Alt-d. And when you find a linux box that doesn't work with your new tricks, try adding the above code to your .inputrc.

Do a man bash to learn more.

No comments:

Post a Comment