How to Clear Mac Terminal History

The list of all the commands that you have executed on your Mac Terminal is stored in the .zsh_history hidden file that you can find in your home directory.

% cat ~/.zsh_history

cd ~/Desktop
mkdir myrepo
cd myrepo
git init
mkdir module1
mkdir module2
cd module1
cd ..
cd module2
cd ..
git add .
git commit -m "init commit"

You can remove this file or open this file with vi/nano editor and clear all the text it has.

% rm ~/.zsh_history

You will need to close and reopen Terminal.

Now when you will run the history command you would not see your command history.

 % history 
    1  history
    2  rm ~/.zsh_history
Clear Mac Terminal History

Note - if you want to do this for the bash shell, do the same for ~/.bash_history file.


Have Questions? Post them here!