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.

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail:

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap