Suramya's Blog : Welcome to my crazy life…

April 26, 2005

Find and bind key sequences in bash

Filed under: Tutorials — Suramya @ 1:37 PM

This Tip was taken from a TechRepublic article by Vincent Danen. It will allow the user to map unused key combinations to run custom commands in the shell.

To obtain the key sequence from a function key, use the read command. The following is an example of pressing the [F12] key:

$ read


Note that different keyboards will produce different key sequences, and modifiers to the function keys (such as [Ctrl][F12] or [Shift][F12]) will produce other sequences as well.

The next step is to bind that key sequence to a particular shell command. For example, you can bind [F12] to the ‘history-search-backward’ shell command:

$ bind ‘’\e[24~’: history-search-backward’

– Suramya

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress