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 http://wiki.bash-hackers.org/internals/shell_options#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.
About the author
I'm currently working on short form content at ClickHouse. I publish short 5 minute videos showing how to solve data problems on YouTube @LearnDataWithMark. I previously worked on graph analytics at Neo4j, where I also co-authored the O'Reilly Graph Algorithms Book with Amy Hodler.