Why care about readline?

Readline is a program that enables manipulation of text at the command line prompt of several different shells. If you’ve ever wondered how to search history back and forth in bash using arrow keys or use vi/emacs mode in bash, then you’ve actually been inquiring about readline support. This is only a taste of what’s possible; more can be found at Bindable Readline Commands.

The basics of readline include creating an .inputrc file in your home directory ~/. Nearly any program that uses readline will read the settings in your .inputrc, and nearly all command line based programs use readline.

My .inputrc is super simple and reads like:


set editing-mode vi

"\e[A": history-search-backward
"\e[B": history-search-forward

It’s not exactly a standard program, either. You’ll never have to invoke it from the command line, for instance. It’s installed by default in a folder called ‘include’ which can be either /usr/include or /opt/local/include, for instance. The code in these directories gets compiled into other programs.

Again, much more can be done with readline. While this should get anyone started on learning more about readline, the best source of info is probably its official site.

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s