Subject: Re: command-line editing and "standard" shells....
To: NetBSD-current Discussion List <current-users@netbsd.org>
From: Greg A. Woods <woods@most.weird.com>
List: current-users
Date: 03/18/1999 18:19:17
[ On Thursday, March 18, 1999 at 11:41:13 (-0400), David Maxwell wrote: ]
> Subject: Re: command-line editing and "standard" shells....
>
> But no one has argued using ksh, just sh or csh.
NetBSD's /bin/ksh is pd-ksh and it seems to be in a race with NetBSD's
/bin/sh to see which is more POSIX compliant, etc.
I.e. there may come a day when someone officially does 'mv ksh sh' and
the already tiny distinction will completely disappear.... ;-)
> What shell, as NetBSD is shipped now, can a user press (cursor-up) and
> see their previous command? (and edit it) Despite the fact that I know
> you're an Emacs person Greg, and I, vi, non-cursor keyed command recall
> is non-intuitive, which is true for 'EscK' and '^A'
/bin/sh and /bin/ksh both support cursor keys. Once you enable
command-line editing, cursor keys work. PD-ksh currently has the
advantage because setting 'EDITOR' and/or 'VISUAL' to some string that
stars with either "vi" or "emacs" will automatically select and enable
the desired command-line editing mode.
There may be dependencies in either shell's support of cursor keys on
the terminal type, or whether or not a termcap entry is available, etc.,
but I do know they work fine in xterms and ansi terminals.
Shell command-line editing is intuitive for vi or emacs users, and for
all others there's the manual page and lots of practice! ;-)
> It doesn't work that way out of the box though, you needed to find the
> 'magic cursor-key aliases' and set them up.
The cursor key aliases are only necessary with real Ksh (at least in
older versions). Pd-ksh supports cursor-key editing "out-of-the-box".
Note from the pd-ksh manual page that these bindings are there by
default:
[[....]] The following binds
the arrow keys on an ANSI terminal, or xterm (these
are in the default bindings). Of course some
escape sequences won't work out quite this nicely:
bind '^[['=prefix-2
bind '^XA'=up-history
bind '^XB'=down-history
bind '^XC'=forward-char
bind '^XD'=backward-char
In real Ksh Version M-12/28/93f, which anyone running NetBSD/i386 or
NetBSD/sparc can download for essentially free and run, I've not yet
been able to get the cursor key bindings settings to work, though they
should work according to the manual page:
M-letter Soft-key - Your alias list is searched for an
alias by the name _letter and if an alias of
this name is defined, its value will be inserted
on the input queue. The letter must not be one
of the above meta-functions.
M-[letter Soft-key - Your alias list is searched for an
alias by the name __letter and if an alias of
this name is defined, its value will be inserted
on the input queue. The can be used to program
functions keys on many terminals.
> It's a lot harder to type a whole line wrong, character by character, than
> to do a recall (visual or not) and hit enter at a bad moment.
OK, yes, I agree -- that is what I thought you meant, but then you gave
the example of '!d'.... ;-)
--
Greg A. Woods
+1 416 218-0098 VE3TCP <gwoods@acm.org> <robohack!woods>
Planix, Inc. <woods@planix.com>; Secrets of the Weird <woods@weird.com>