Decades ago, I was taught to use `!` and Co, by a Linux user who was fond of the `sudo !!` trick. Then I switched from this implicit interpolation to explicit shortcuts, and I'm glad I did.
As suggested in the FAQ at the bottom, instead of !… you can use ctrl-r. Or better, optionally type the first letters then alt-p or "up". It's more powerful and more extensible. Other shortcuts, like alt-., allow navigating into the past parameters.
With up, alt-p, alt-. and such, the command line displays the real command. The !… magic is more error-prone and ambiguous; with zsh, I'd suggest hitting TAB to expand the magic into a static text.
I would add other entries to the FAQ: When I enter `sudo !!` will it be stored unchanged in the shell history, or stored after interpolation of `!!`? When I start a command line with a space, so that zsh does not put it in the shell history, will !… also ignore that line? Is `!$` recursive?
Your questions would be a great addition to the FAQ, thank you!
--
> When I enter `sudo !!` will it be stored unchanged in the shell history, or stored after interpolation of `!!`?
event-designators themselves do not end up in history, it will be the expanded contents:
The above is ironically enough quite annoying when writing a post about event-designators, as you'd want to reach for previous pre-interpolation commands.> When I start a command line with a space, so that zsh does not put it in the shell history, will !… also ignore that line?
leading space to ignore adding things to the history is not default behavior, but event designators will still be able to capture their contents. Notice how "echo 321" is _not_ part of the history, but our usage of !$ is:
> Is `!$` recursive?I think this is indirectly answered by the above, if not let me know and I will see if I can answer.
---
Will try to update the post within the next few hours with your additional questions — much much appreciate the feedback, and thanks for reading!