The Terminal app in macOS keeps track of recent commands you’ve used so you can reuse them at a later time. Here’s how to clear Terminal’s command history.
When you type commands and press return in macOS’s Terminal app, it remembers the commands you type and stores them, in case you want to reuse the same commands again later.In Terminal, you can press the Up and Down arrow keys on your Mac’s keyboard to cycle through all recent commands. As you do, Terminal replaces whatever is on the command line prompt with each command in the stored command history as you press the arrow keys.
How to clear Terminal’s command history in macOS
How to clear Terminal’s command history in macOS