Command line editing
Command completion
See also
With command line editing, you’ll notice immediately how much easier it is do things quickly without a lot of retyping. As you try the examples, notice how the , Insert, Delete, Home, End and other keys can be used to recall previous commands or make changes anywhere on the line.
Command line editing is like having a full-screen editor pasted onto the front end of the shell. Key bindings are intuitive and follow accepted conventions. You can create enormous commands that stretch over screen after screen and move around with the arrow keys, inserting or deleting anywhere. A scrap buffer provides a basic cut-and-paste facility.
The basic key assignments are:
Insert
Toggle between insert and overstrike modes. (The cursor is thicker when you’re inserting.)
Home End
Beginning / end of command line.
One character left / right.
Up/down one command in the history list.
Ctrl-
Move one word at a time. Similarly, with the other arrow keys.
Alt-
Delete one word at a time. Similarly, with the other arrow keys.
Ctrl-Insert
Paste one word at a time.
Alt-Insert
Paste the entire contents of the scrap buffer.
If you don’t have an Alt key, use Ctrl-Shift instead.
In addition to backing up through your previous commands one at a time with Up and Down, you can also ask the shell to search back through any previous commands you’ve typed for the last command that either started with or contained the characters in the previous word.
Ctrl-Enter
Find the previous command that started with the characters of the preceding word.
Ctrl-Shift-Enter
Find the previous command that contained the characters of the preceding word anywhere on the line.
Repeatedly pressing these keys cycles up through all the matching commands you’ve previously typed. Command completion uses something called the history mechanism to recall commands you’ve previously typed. Later, we’ll devote a whole chapter to some of the more advanced uses of history.
Command line editing
Command completion
Filename completion
History recall
Tutorial: Filename completion
Tutorial: History