How do I clear old directories and commands in Terminal on MacBook Pro?

I have old directories and commands in terminal I need to get ride of. Any help would be greatly appreciated. I'd like to return terminal to factory settings. I have already uninstalled Homebrew.


[Re-Titled by Moderator]

MacBook Pro 14″, macOS 15.3

Posted on Mar 29, 2025 7:29 AM

Reply
13 replies
Sort By: 

Mar 29, 2025 10:17 AM in response to dislover

dislover wrote:

Is there a way just to return terminal to "factory settings"?


In Terminal's settings click the "Restore Settings"



If that doesn't work then delete Terminal's plist.


If they don't work then it might be that you didn't uninstall Homebrew correctly and it's left stuff behind . I can't help much there - google is probably best.

Reply

Mar 29, 2025 8:45 AM in response to dislover

I erred in my first reply as that clears the history only for the current session. The history remains after you quit and relaunch Terminal.


The guidance I offered in my second post clears the history and works across sessions. The history remains unless/until you quit Terminal.


Reply

Mar 29, 2025 9:18 AM in response to dislover

First of all: https://apple.stackexchange.com/questions/388622/zsh-zprofile-zshrc-zlogin-what-goes-where.


Notwithstanding that article, using ZSH on macOS doesn't automatically create or populate a .zprofile file, so you must have either had a .bash_profile at one point or created a .zprofile...


Something in .zprofile references /opt/homebrew/bin/brew and the fact you uninstalled Homebrew means that when the line in .zprofile is run on starting a login shell, the line fails for obvious reasons.


Something similar is happening with .zshrc - although since you redacted the command itself, I can't provide any further insights.


In any case, you need to go into the Terminal, and edit those two files - at lines 2 & 4 and lines 1 & 10 respectivley, to fix whatever is wrong with them. The built-in command line editors include vim, nano and pico.


BTW, the "cat" command simply copies the contents of the input somewhere (it's short for "concatenate") - usually from a file to the standard output in Terminal.


cat /User/<your profile name>/.zprofile


will dump the contents of .zprofile to your screen so you can read them and see what's wrong before trying to edit it with


vim /User/<your profile name>/.zprofile


I recommend glancing at some online help for vim (or whatever) before trying to use it, since some of the controls are not intuitive.

Reply

Mar 29, 2025 10:02 AM in response to dislover

It's not terminal, it's your login shell profile. Yes you can "factory reset" that - you just delete .zprofile, .zshrc and .zshenv if they exist.


BUT - if you don't know what they are currently doing, then you don't know what else may break that is relying on whatever changes were set in those files. You should at least look over the contents (and post here if helpful).


Also, I hope your other comment about redacting your password was a mistake? Your password should never appear anywhere visible, such that it would need to be redacted...

Reply

Mar 29, 2025 10:32 AM in response to dislover

Your zsh login scripts have old content. Either edit it and remove, or replace it.


Which of the scripts has old content varies by context.


In this particular case, .zprofile lines 2 and 4 are bad, and .zsrc lines 1 and 10 are bad. You can “#” comment those four lines as a test.


If you’re not familiar with a command-line editor, pico (recent) or nano (older) can be a good choice. The common commands are shown at the bottom of the pico (or nano) display, and command summaries are available.


Here are the zsh login script details: https://unix.stackexchange.com/a/71258

Reply

How do I clear old directories and commands in Terminal on MacBook Pro?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.