I simply realized that executing r
in my terminal, reruns the earlier command. #wat
r
is a built-in shell command in my zsh setup.
$ which r
r: shell built-in command
Should you test all of the built-in zsh instructions with man zshbuiltins
, you will obtain the unhelpful data that r
command is similar as fc -e -
.
r — Identical as fc -e -
Alright, I will chew, what’s fc
?
fc
is included within the zsh built-ins, too. The fc
command enables you to show, edit or execute instructions from the shell historical past, however sadly, the zsh man pages fail to reply what fc
really stands for.
Some people say fc
stands for “fix command” whereas others advocate for “find command”. Each definitions make sense, however I did not see it written within the zsh / bash man pages.
fc
is useful when juggling lengthy and complex shell magic that requires enhancing and rerunning.
However what’s up with this r
command standing for fc -e -
?
The fast reply: r
makes use of fc
to rerun the beforehand executed command with out the choice to alter it.
$ echo "howdy world"
howdy world
$ r
echo "howdy world"
howdy world
You may as well slim and search the command to run by calling r
with further arguments. For instance, r ls
will rerun the beforehand run ls
command.
$ ls -lah
...
$
$
$
$ r ls
ls -lah
...
However the place is that this execution habits documented? Truthfully, I’ve no clue…
In keeping with the fc
documentation, the -e
flag permits you to outline the used editor earlier than rerunning the command, however -e
appears to unlock some superpowers when paired with -
. Sadly, I could not discover this habits described anyplace.
Nonetheless, r
is a really handy method to rerun a command with out reaching for the arrow keys!
When you’ve got extra insights, please let me know.