[vox-tech] vi key bindings, readline and bash

Charles Polisher vox-tech@lists.lugod.org
Tue, 25 Mar 2003 15:32:39 -0800


Peter Jay Salzman wrote:

> > > > does it work for anybody?
> > > 
> > > Not here.
> > 
> > SuSE does the right thing as-is; this is from /etc/inputrc :
> > 	$if mode=vi
> > 	set editing-mode vi
> > 	set keymap vi
> > 	$endif
> > and the environment has INPUTRC set to "/etc/inputrc",
> > but that can be overridden with ~/.inputrc (bash refman p.82)
> 
> hi chuck,
> 
> i'm not sure how that can possibly be; seems really impossible.   just
> to make absolutely sure, beyond a shadow of a doubt, can you tell me
> what you mean by "does the right thing"?
> 
> there needs to be more than this, unless suse started hacking on
> readline source code...

"Does the right thing":
>From an ordinary bash prompt, with a typical U.S. installation
of SuSE Linux 8.0, inside a standard xterm, logged in as an
ordinary user, with no further customizations of the shell, 
press the up-arrow key. The shell displays the most recently
typed command from the shell history, without moving the cursor
to a different line, but positioning the cursor just beyond the
last character of the command. At this point, pressing the
Enter key causes that displayed command to execute. Additional
up-arrow key presses will go further back in the shell history,
while down-arrow replaces the displayed command with more recent
commands. 

"set keymap vi" is part of the standard Gnu bash distribution,
as documented in the Bash Reference Manual, 2.5a-th ed., 11/2001.

Thusly speaketh the man page (excuse please the fleckths of
thspittle on the thscreen, I blame the dentithst):

       keymap (emacs)
              Set the current readline keymap.  The set of  valid
              keymap  names is emacs, emacs-standard, emacs-meta,
              emacs-ctlx, vi, vi-command, and vi-insert.   vi  is
              equivalent  to  vi-command;  emacs is equivalent to
              emacs-standard.  The default value  is  emacs;  the
              value  of  editing-mode  also  affects  the default
              keymap.

That "(emacs)" in the first line gives the default value.
Also, under man 3 readline, the section on default key
bindings lists the complete "VI Mode bindings". Werner Fink
is credited with the inputrc file, which also has these lines:

$if term=xterm
"\e[5;5~":  history-search-backward
"\e[6;5~":  history-search-forward
$endif
"\e[C":     forward-char
"\e[D":     backward-char
"\e[A":     previous-history
"\e[B":     next-history

Maybe that's the magic you've been looking for?

-- 
Violence is the last resort of the incompetent. The competent,
of course, make it their *first* resort.