This chapter describes the optional command line editing feature of Glish. Command line editing is implemented using a modified version of the original editline library (see the editline/README and editline/COPYING distribution files full information). This library provides was written by Simmule Turner and Rich Salz, and was modified to work within Glish's asynchronous event constraints.
Command line editing allows users to re-execute previous commands, fix
problems with the current command, or search for a previous command matching
a particular substring. These operations are are performed based on
emacs-like control characters. Table 12.1 summarizes
the editing commands. These can be use at any time when entering a command.
The notation C-<CHAR>
means that the character
<CHAR>
is typed while the CONTROL key is held down. So
C-b is known as control-b. The notation M-<CHAR>
means that the META key is held down while <CHAR>
is typed or
the ESCAPE key is pressed before pressing <CHAR>
. So
M-b is known as meta-b or escape-b. In addition, BACKSPACE
stands for the ``backspace key'', DELETE stands for the ``delete key'',
RETURN stands for the ``return key'', and UP-ARROW, DOWN-ARROW,
LEFT-ARROW, and RIGHT-ARROW stand for the up, down, left, and right
keys common on most keyboards.
Use of these commands can become relatively natural, and they are a great aid when working with the CLI. For the users who are not interested in all of the control characters, backspace, delete, and the arrow keys perform as expected, and should provide most of what these users need.
There is currently one know command line editing related bug which should be fixed in the future. C-z does not suspend Glish (with command line editing).
Command | Action |
C-p or UP-ARROW | get the previous command |
C-n or DOWN-ARROW | get the next command |
C-a | go to beginning of line |
C-e | go to end of line |
C-b or LEFT-ARROW | move back (to the left) one character |
C-f or RIGHT-ARROW | move forward (to the right) one character |
C-d | delete the current character. Note C-d on an empty line exits Glish. |
C-h or BACKSPACE or DELETE | delete the previous (to the left) character |
C-k | kill from the current character to the end of the line |
C-y | yank back any previously killed character before the current character |
C-l | redisplay the current line |
C-]<CHAR> | move to the single
character <CHAR> |
C-t | transpose current and previous character |
C-r | search for a string. Enter the string followed by RETURN when prompted with Search:. Just pressing return when prompted uses the last search string. |
M-b | move back (to the left) one word |
M-f | move forward (to the right) one word |
M-d | delete from the current position to the end of the word |
M-l | toggle to lower case from the current position to the end of the current word |
M-u | toggle to upper case from the current position to the end of the current word |
M-< | get the first history line |
M-> | get the last history line. This is often used to restart a search. |
M-C-h or M-BACKSPACE or M-DELETE, | delete from the current position to the beginning of the current word |
M-w | copy from the current position to the beginning of the line to the kill buffer for a later yank |