How to disable the confirmation of history expansions like `!!`

Zsh takes real good care of me, and at times it can get a bit too much. One of the times where I'd rather have it stay out of my business is when it "wants to make sure I want to execute the given command". The functions I am experiencing this with are:

The commands:
sudo !! - run previous command prefixed with sudo
and
^old^new - run previous command, but substitute the first occurrence of "old" with "new"


The problem:
When I type in one of the two commands listed above and hit Enter, instead of running the command instantly, the command expands to what is actually going to be run, and I have to hit Enter once again to actually execute it. First world problem, but still.

1 $ pwd
2 /home/neil
3 $ sudo !!
4 $ sudo pwd
5 /home/neil

I'd like to skip step 4. This is skipped by default in bash.


Solution 1:

That's easy... if you know the corresponding option:

unsetopt HIST_VERIFY

Put this in your ~/.zshrc and do source ~/.zshrc if you want that behavior to be permanent.

Explanation from man zshoptions:

HIST_VERIFY Whenever the user enters a line with history expansion, don't execute the line directly; instead, perform history expansion and reload the line into the editing buffer.