Return
|
You want to edit and recall commands entered at the Korn shell (command line) prompt.
Set the Korn Shell (ksh) to use the editing conventions of your favor Unix editor. Note that unlike VMS, the command line editing conventions established for the shell do not necessarily extend into other interactive applications. But having the shell follow (more or less) the line editing conventions used by your preferred text editor is a significant convenience.
Please see the Typographical Conventions page for more information on the control-key notations used below.
To start with, your .profile
file should contain the following two commands to set your
terminal:
stty dec tset -I -QThis is assuming that you are using the same terminal or terminal emulator as you normally used on VMS. These settings should make the key that you are use to hitting for 'rubbing out' the previous character work as expected. This key is known in Unix as the 'erase' key. In addition,
C-u
will erase the current command entry, which is similar to
what it does under VMS.
This key is called the 'kill' key.
Command line editing is not turned on by default for ksh (although
your site adminstrator may have provided local initialization files
that have turned it on for you). This is because there are two
fundamental styles of command line recall, modeled after the two
predominant editors, vi and Emacs. To enable command line editing,
set the EDITOR shell variable using one of the
following:
unix> EDITOR="vi"; export EDITOR
... or ...
unix> EDITOR="emacs"; export EDITOR
The EDITOR environment variable is not only used by
ksh to determine the command line editing style, but also other
applications and utilities, such as crontab
when it is necessary to invoke an editor on your behalf. See
1.6 for information on how to setting
your preference every time you logon. For reasons explained in
Emacs for
the EVE User we discuss only the Emacs environment in this
article. Consider the following table:
| DCL | Ksh | Action |
|---|---|---|
C-a |
-- |
Toggle insert/overstrick mode. |
C-u |
-- |
Delete from cursor to beginning of line. |
-- |
C-u |
Delete entire command line. |
C-h |
C-a |
Go to start of line. |
C-e |
C-e |
Go to end of line. |
C-r |
C-l |
Refresh current line. |
C-j |
ESC C-h |
Erase previous word. |
-- |
ESC f |
Forward one word. |
-- |
ESC b |
Backward one word. |
-- |
C-] x |
Jump forward to character 'x'. |
-- |
ESC C-] x |
Jump backward to character 'x'. |
-- |
C-d |
Delete character under cursor. |
-- |
ESC d |
Delete current word. |
-- |
C-t |
Transpose current and next character. |
-- |
C-k |
Delete from cursor to end of line. |
-- |
C-r |
Incremental reverse search through command history. |
-- |
ESC ESC |
Complete as much as possible of filename entered so far. |
-- |
ESC = |
Show list of files that match filename entered so far. |
-- |
ESC * |
Generate list of all files matching filename entered so far. |
The arrow keys are not shown above since they operate exactly as you would expect having come from DCL. However the control-keys used for command line editing are almost entirely different.
While most of the keys described are self-explanatory a few deserve special mention:
Rather than using the up-arrow key repeatedly in search of
a specific command, you can find previous commands using a
search string instead. Press C-r immediately
followed by a substring to be matched, and press
RET. The most recent command matched will be
displayed. Press C-r immediately followed by
RET and the next matching
command before that is displayed, and so on. To
anchor the search to the beginning of the line, use the
up-arrow character. Thus ^ls would match only
lines starting with "ls".
ksh can enter long filenames for you. After typing the
first few characters of a filename, press the
ESC key twice -- the shell will fill in as
much of the filename as possible. If the string is unique,
the entire filename is displayed. The name will end with a
space if it is a normal file, or a / if it is
a directory. Using this technique, it is possible to enter
a very long path and filename using relatively few
keystrokes.
Likewise the ESC = key sequence can be used to
display those files that match the text entered so far, and
ESC * will enter all matching files on the command line
for you.
Some final notes:
The current version of the Korn Shell (M-11/16/88f) available under Compaq's Tru64 Unix V5.1 does not appear to support any way of changing key mappings.
Be aware that the BASH (GNU Bourne-Again
SHell) has similiar, and largely compatible ksh command-line
editing capabilities and an even more powerful and convenient to
use filename completion functions based on the TAB
key (and the TAB key is what emacs uses for it's own file name
completion). For more information type man bash at the
shell prompt and/or see the
BASH
reference manual.
1.2 - Interactive Job Control;
1.6 - Environment Initialization;
Chapter 3 of Unix for OpenVMS Users
.
  Return
|
|
Colophon: |
|
||||
|
This page maintained by: Bill.Costa@unh.edu of the Enterprise Computing Group in the dept of Computing & Information Sevices at the University of New Hampshire |
|
||||