Zsh !! and !$ auto execute as it does in bash

command historyzsh

I recently made the switch from bash to zsh. I discovered two minuscule issues and differences between zsh and bash. I was slightly disappointed when my favorite two shortcuts !! & !$ don't behave as they do in bash.

When I try to the following with the argument shortcuts (sorry I don't know what they're formally called) they would automatically execute like the following in bash:

$ touch foo
$ vim !$
<file opens immediately>

While in zsh they become translated then executed (I have to hit enter one extra time):

$ touch foo
$ vim !$
$ vim foo

Is there a way to have !$ & !!, in zsh, behave the same way as it does in bash?

Best Answer

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.

To disable this option run setopt no_hist_verify. You can also have a look at your config file and remove the hist_verify option or just explicitly disable it.

Related Question