· zsh

zsh: Don't verify substituted history expansion a.k.a. disabling histverify

I use zsh on my Mac terminal and in general I prefer it to bash but it has an annoying default setting whereby when you try to repeat a command via substituted history expansion it asks you to verify that.

For example let’s say by mistake I try to vi into a directory rather than cd’ing into it:

vi ~/.oh-my-zsh

If I try to cd into the directory by using ‘!$’ to grab the last argument from the previous command it will make me confirm that I want to do this:

$ cd !$
$ cd ~/.oh-my-zsh

While reading another one of Peter Krumins’ blog posts, this time about bash command line history, I came to learn that this is because a setting called histverify has been enabled.

histverify Allow to review a history substitution result by loading the resulting line into the editing buffer, rather than directly executing it.

I found a thread on StackOverflow which explains all the zsh settings in more detail but for my purposes I needed to run the following command to disable histverify:

unsetopt histverify

I also put that into my ~/.zshrc file so it will carry across to any new terminal sessions that I open.

  • LinkedIn
  • Tumblr
  • Reddit
  • Google+
  • Pinterest
  • Pocket