
Command History | 645
Bash and Korn
This is the Title of the Book, eMatter Edition
Copyright © 2006 O’Reilly & Associates, Inc. All rights reserved.
chosen not to cover those features here. See the Bash manpage for more
information.
Line-Edit Mode
Line-edit mode emulates many features of the vi and emacs editors. The history
list is treated like a file. When the editor is invoked, you type editing keystrokes to
move to the command line you want to execute. You can also change the line
before executing it. When you’re ready to issue the command, press the Enter
key.
In ksh, line-edit mode can be started in several ways. For example, these are
equivalent:
$ VISUAL=vi
$ EDITOR=vi
$ set -o vi Overrides value of VISUAL or EDITOR
For Bash, you must use either set -o vi or set -o emacs; assignment to the VISUAL
or EDITOR variables has no effect.
Note that vi starts in input mode; to type a vi command, press the Escape key
first.
Bash also provides a csh-style command-line editing mechanism, which we don’t
cover because the built-in vi and Emacs editing modes are easier to use.
Common editing keystrokes
The fc and hist Commands
“fc” stands for either “find command” or “fix command,” since it does both jobs.
Use fc -l to list history commands and fc -e to edit them. See the fc entry in the
later section “Built-in Commands (Bash and Korn Shells)” for more information.
vi emacs Result
k Ctrl-P Get previous command. ...