from small one page howto to huge articles all in one place
 

search text in:





Poll
Which filesystem do you use?






poll results

Last additions:
using iotop to find disk usage hogs

using iotop to find disk usage hogs

words:

887

views:

195648

userrating:

average rating: 1.7 (102 votes) (1=very good 6=terrible)


May 25th. 2007:
Words

486

Views

252053

why adblockers are bad


Workaround and fixes for the current Core Dump Handling vulnerability affected kernels

Workaround and fixes for the current Core Dump Handling vulnerability affected kernels

words:

161

views:

140918

userrating:

average rating: 1.4 (42 votes) (1=very good 6=terrible)


April, 26th. 2006:

Druckversion . pdf icon
You are here: System

Assign commands to key

A lot of programs (esspecially Bash) use the GNU Readline library for command line input. Readline allows to define each key with a custom value. This definition is stored in the file .inputrc in the users home directory.

If you want to assign an often used command, e.g. less /var/log/message to the key F1, you'll need to add the following line to your .inputrc:

"e[11~": "less /var/log/messages^M"

The last char in e[11~ is a tilde char. All characters have to be entered exactly as given, with only one exception: the ^M at the end. The ^M means Enter and causes a direct execution of the command. Without the ^M, the
command would be simply copied into the command line and which would wait for the input of enter or a different char.

The way you enter the ^M depends on the editor you use. In vi you have to press ctrl-V and Enter.
It has to be one single char (ASCII-code 13).

The character sequence e will be interpreted as an Escape char from Readline. The given sequence works in X11. In the console the sequence differs, but both definitions can be in the same .inputrc file.

The change in .inputrc applies with a fresh started Shell. You can refresh the setting with the key sequence ctrl-X and ctrl-R in the running shell. F1 should work now.

How to use the trick with other keys? First you have to know the code that the key generates.

You can get the code when you press ctrl-V and the desired key.

You will get an Escape-sequence (the first 2 chars are ^[ which is equal to ctrl-[ and equal to Escape)

If you replace ^[ with e, you got the sequence for .inputrc.

More details of the usage of readline can be found in the bash manpage (man bash).

Translated from

http://www.pro-linux.de/news/2002/0040.html


rate this article:
current rating: average rating: 1.6 (16 votes) (1=very good 6=terrible)
Your rating:
Very good (1) Good (2) ok (3) average (4) bad (5) terrible (6)

back





Support us on Content Nation
rdf newsfeed | rss newsfeed | Atom newsfeed
- Powered by LeopardCMS - Running on Gentoo -
Copyright 2004-2020 Sascha Nitsch Unternehmensberatung GmbH
Valid XHTML1.1 : Valid CSS : buttonmaker
- Level Triple-A Conformance to Web Content Accessibility Guidelines 1.0 -
- Copyright and legal notices -
Time to create this page: 71.9 ms