For a while, running commands and scripts in macOS’ Terminal has felt slower than it should, especially when opening Terminal for the first time. Clearly my .zshrc
file was being run, but there was a very noticeable pause between the completion of the script and before the prompt appeared. The gap was much less on my M1 Mac than my Intel machine, but still noticeable. Got the same problem? Here’s how to fix it.
What I happened to notice was the appearance of xcodebuild
, part of Apple’s Xcode command line tools, in the Terminal window title bar. I have Terminal set to show the current working directory path and the currently executing program. I Googled xcodebuild terminal slow
and found a possible answer: it’s something to do with Apple’s version of git. I tried one suggested fix, but no joy.
A second suggestion did it though, but I didn’t notice until I restarted Terminal. So, to ensure I have a record for the next time it crops up, here’s the fix:
To see which git you are running, run Terminal and enter:
which git
You’ll probably see /usr/bin/git
. You can’t delete this file, at least not in Big Sur, but no matter.
Now run:
brew install git
You’ll need to have Homebrew installed, of course.
Not only does Homebrew install a slightly more recent version of git, it aliases it so that’s the one preferred by your system. BUT, you’ll have to open a new Terminal window or tab to see it. When you’ve done so, you can re-run which git
, and you’ll see either /usr/local/bin/git
or /opt/homebrew/git
depending on whether you’re using an Intel or ARM Mac.
I’m pretty sure I went through this process ages ago, just to get a more recent version of git, but clearly I stuck with the Xcode-installed one the last time I rebuilt my machine or when I got a new computer. Since both of those events will surely happen again — I periodically erase my computer and re-install everything from scratch — I’m writing this down now — so I’m ready to fix ‘Terminal slowdown’ next time.
I already had git installed via brew, while still experiencing this issue.
For whatever reason i was using the osx zsh-plugin. Also removing that did the trick.
Thank you so much! I’ve been annoyed by it for months.
Thanks for telling how to fix this problem.