If you want to maintain your command history in your shell when using ZSH or Bash do the following:

  1. Using your favourite text editor, open .zshrc if you are using Z shell or .bashrc if you are using Bash shell in your home directory.

  2. Add the following to the config file of the shell:

# Large in-session history (up-arrow navigation within the tab)
HISTSIZE=10000

# Prevent writing history to disk entirely
SAVEHIST=0
HISTFILE=/dev/null

# (Optional) Ensure history is NOT shared between tabs or appended across sessions
unsetopt SHARE_HISTORY
unsetopt INC_APPEND_HISTORY
unsetopt APPEND_HISTORY
  1. Save the file.

  2. Reload the config file for the shell by typing source ~/.zshrc or source ~/.bashrc depending on the shell that you are using.

  3. Your new settings should have taken effect.