Alternative to "fc -s" in zsh?
In bash
, I had a handy alias:
alias r="fc -s"
Which just repeated last command. Same as !!
. I am now used to it (muscle memory), but I can't seem to figure out how to recreate the alias. fc
doesn't have -s
option in zsh
. How can I bind !!
behavior to r
?
The command
fc -e -
should do what you want. This is a little bit tricky, because fc -e [edit-cmd]
usually lets you edit tha last command with an editor. But if the [edit-cmd]
equals -
, no editor is invoked and the command is executed immediately.
But you won't need an alias for that, because the command r
is already defined in the Z shell:
$ which r
r: shell built-in command
And what does it do? The zshbuiltins man page does know it:
r
Same asfc -e -
.