fcis a zsh builtin command that lets you recall, edit, and execute previous commands.
There are two forms of
The syntax of the first form is:
fc [ -e EDITOR ] [ OPTIONS ] [ old=new ... ] [ first [ last ] ]
Also, see syntax notes
This will select commands from the history list between
last can either be numbers or
strings. A number specifies the event (command) number from the
history file (1). A
string specifies the most recent command that begins with that string.
the substitutions you specified (
old=new pairs) are performed on the commands.
Any occurance of
old in the commands
is replaced with
-loption, the selected commands are simply displayed; nothing else happens. (This is the same as typing
historyon the command line)
fc normally prints command numbers
before each command. To get rid of those numbers, add the
Many other flags are used in conjunction with
To display time stamps of the selected commands, use the
-d option. If you'd like full time-date stamps, use the
-f option instead of
-d. Don't like the
format of the time stamps? Try the
-E flag, or the
-i flag. To display the elapsed time between each command
line, use the
-m flag in conjunction with
you can specify a pattern. (don't forget to quote the pattern!). Then,
only commands matching the pattern will be displayed.
The key idea here is that when the file is done being edited, all commands in it will be executed upon leaving the editor.
Another handy option to the first form, whether listing OR editing, is
-r flag. It reverses the order of the selected
fc -ARWI [ filename ]
-R will read the history from the given file
-W will write the history to the given file
-A will append the history to the given file
Adding the -I option causes only those events that are new since the last incremental append was done.
In all of the above cases, the history file never has more than