--
> 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:
$ echo "hello world"
hello world
$ echo !$:s/world/idoubtit/
echo "hello idoubtit"
hello idoubtit
$ history
1 echo "hello world"
2 echo "hello idoubtit"
3 history
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:
% setopt HIST_IGNORE_SPACE
% echo "abc"
abc
% echo "321"
321
% echo last-argument-was !$
echo last-argument-was "321"
last-argument-was 321
% history
22092 setopt HIST_IGNORE_SPACE
22093 echo "abc"
22094 echo last-argument-was "321"
> 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!