I accidentally typed r
into the shell and got what appeared to be a repeat of the last command I ran.
man zshbuiltins
, unhelpfully, says this:
r
- Same asfc -e -
.
The documentation for fc
is almost impenetrable but I managed to tease out these quotes:
fc [ -e
ename
] [ -LI ] [ -m
match
] [
old=new
... ] [
first
[
last
] ]
the editor program ename is invoked on a file containing these history events....When editing is complete, the edited command is executed.
If ename is
-
, no editor is invoked.
This reads to me like the behavior of r
is similar to exclamation point !
, in that it replays history. Indeed, if I setopt banghist
to turn bang back on, things like r man
and ! man
both seem to replay my last call to man.
What are the similarities and differences between r
and !
? What's a hypothetical scenario in which I could use r
?