This used to be the default behavior on iTerm2 before I upgraded to macOS Calalina.
02 Answers
This is not configured in iTerm2, but is set by macOS in Zsh itself. Since macOS Catalina, the file /etc/zshrc contains the following:
HISTFILE=${ZDOTDIR:-$HOME}/.zsh_history HISTSIZE=2000 SAVEHIST=1000 This causes the last 1K lines of history to be saved on exit.
To override this, add the following to your ~/.zshrc file:
unset HISTFILE SAVEHIST 1Step 1.
%> echo "\n# Clear ZSH history after each exit.\ntrap 'unset HISTFILE; rm ~/.zsh_history;HISTSIZE=0;'" >> .zshrc
Now reload your ZSH terminal and you will never have history saved again unless you remove the above line from your .zshrc :).
You're done!