[Ilugc] Key Bindings

  • From: kapil@xxxxxxxxxxx (Kapil Hari Paranjape)
  • Date: Thu Sep 3 12:23:54 2009

Hello,

On Thu, 03 Sep 2009, Girish Venkatachalam wrote:

On Thu, Sep 3, 2009 at 10:17 AM, Kapil Hari Paranjape<kapil@xxxxxxxxxxx> 
wrote:
Overall, I have found that messing around with loadkeys is only
useful if you _only_ use the Linux console. Even in that case it is
better to define key sequences in specific applications rather than
replacing the characters that the console stuffs into the buffer.

Sorry but I beg to differ.

I even think that you could be wrong here. We are only replacing
the string buffer , and in this case for F1 it was a totally
useless representation. We are not really diddling with the
keycodes or anything like that.

The problem is that you may accidentally hit "F1" while in application
"foo" for which "ls -l\n" is a command that deletes all your files! :-(

(If you have read the book "Hitchhiker's guide to the galaxy" then
there is some point where it warns that "Careless words can cost
lives"; this is a similar situation).

One way to make it work for bash regardless of which terminal you open
(console, xterm, gnome-terminal, etc.) is long as it generates the
same sequence "ESC+[OP" for F1 is to configure this in ~\.inputrc as
follows:

 $if bash
 "\e[OP": "ls -l\n"
 $endif

This definition will not mess with _any_ other application.

Most terminal applications (vi,emacs,mc,git,screen ...) and a few
graphical ones (like Emacs-with-X, gvim) allow you to assign commands
or character strings to key sequences.

Not useful I think. As I said, the use case is different.

I don't even want to switch on the monitor.

This is one use case for which there is no alternative to loadkeys.

However, you should be aware of Consequences (note the big C). For
example, the Alt+sysrq+r combination is directly grabbed by the kernel
and you can _never_ use it in another application as long as the sysrq
feature is enabled (via proc) --- and it "does" have disastrous
consequences if you happen to be using X or vi at that time.

Regards,

Kapil.
--

Other related posts: