Linux Tip: Arrow keys not working for command input? RLFE to the rescue.

26 01 2012

I’m always wandering across tools in Linux that don’t support line history (up arrow) or the ability to edit lines/move around with the arrow keys. Side note: if you write a Linux tool that takes user commands, stop being lazy and just go link it to the GNU readline library so your command line interface doesn’t make people hate you. There’s nothing more annoying than trying to go back to fix a typo with your arrow keys and getting a pile of gibberish instead of a moving cursor. For example in tclsh,

% puts “stuff goes herr”^[[D^[[D^[[D^[[A^[[C^[[B^[[D <- (typo, right arrow, right arrow, RAAAGE)

The solution? rlfe: the read line front-end processor. It’s got a few bugs, but it works great for things like telnet and tclsh that by default don’t have line history and arrow key navigation.

$ sudo apt-get install rlfe
$ rlfe tclsh

Replace tclsh with practically any command line tool and get back to typing without fear of typos. Plus, you don’t have to keep retyping/copy pasting things when you want to run them again. The rlfe process will stick around after you close the application, so you really only need to run it once with rlfe.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: