super slow OSX Terminal with zsh and oh-my-zsh

Have you ever wondered why coders who are great at Linux have their Terminals looking beautiful with color-coded text? Why do they have a awesome terminal? I wanted a hero-status terminal and maybe you do too. The secret is using different type of Unix/Linux shell, know as the Z shell or [zsh].

OSX Terminal uses [bash] shell by default, and it’s not the most attractive Linux experience. White background and black text and an unfriendly looking prompt, maybe it’s intended to drive away non-coders.

But if you are a developing coder and ready to Level Up your Mac Terminal experience, then install oh–my–zsh in your OSX terminal.

Installed and amped about this new tool, next I started installing homebrew packages

brew install zsh-completions package2 package3

and soon I had 15 packages on my new install. Feeling like a Linux rising star, I showed my hidden files and  opened /.oh-my-zsh/themes and tested them all before settling on [steeef.zsh-theme]. I liked the colors and I was feeling good.

Then I started using my new Terminal with Z shell and oh-my-zsh, it’s sooo beautiful with it’s black background and colored text… and then I realized it was SUPER SLOW. Like 10 secs to load Terminal and 10 seconds between prompts. How could anyone deal with this slowness? How can this only be me on my beautiful zsh Mac Terminal with super slow loads and huge lag time between prompts? This was painfully slow. I couldn’t be the only one… so I started looking around for clues.

I uncovered this was in the oh-my-zsh, since bash was fast, and it was time for debugging. I googled to debug oh-my-zsh slow. I tried all the processes on that page. I commented out NVM, I changed history size.


Nothing changed. Still huge lag times on Terminal load and between prompts.

Another profiling method to find slow plugins/themes/functions is zsh/zprof. Just add

zmodload zsh/zprof

to the top of your .zshrc and then restart Terminal and run env ZSH_PROF= zsh -ic zprof.

This outputs a great report on the status of the zsh packages and their load time. With this report, I see compinit and compdump at the top of the report.
So I think it must be the brew packages. So I uninstall the packages.

brew uninstall zsh-completions package2 package3

Still no change. Still a super slow OSX Terminal with zsh and oh-my-zsh. I’m starting to pull on my hair now. What is the reason for this slowness? I try the next option,

brew install moreutils

This fails on load… multiple times. Seems like the package link is 404 down. I continue forward with the next few options. It’s not the zsh-syntax-highlighting. It’s not the symlinks or the AUTOMOUNTD_VERBOSE=TRUE.

So I keep searching Google. I clean the ASL logs (as described here) helps to reduce the startup time. This does very little, like a fraction of a second. I delete the complete history.zsh file. Still nothing.

Then I finally stumble upon a lead, after hours of debugging this. Large repositories can create long wait times for git.
What? This is one of the core reasons I’m using a Linux Terminal with zsh, so I can use superpower git…

So I find this in the .zshrc file.

# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.

I also try commenting this in the .zshrc file:
# plugins=(git)

Nothing yet… I open Activity Monitor on Mac and watch the CPU tab so I can see what is happening. During Terminal open and between prompts, a git process is appearing while OSX Terminal is lagging super slow. Is this happening for you?

Finally! Now we have a measurable problem and can create a solution. So I wander around trying various solutions for a while before thinking about my ZSH_THEME="steeef". So I open this theme… and it’s full of git calls and git checks. Time to write my own iguchi.zsh-theme.

iguchi.zsh-theme - Create this file in your /.oh-my-zsh/themes folder.
and here are the contents of this new theme.

# built from steeef theme.
# built to fix super slow OSX Terminal with zsh and oh-my-zsh.
# built by Ryan Iguchi - - 10/11/2017


#use extended color palette if available
if [[ $terminfo[colors] -ge 256 ]]; then

%{$turquoise%}%n${PR_RST} at %{$orange%}%m${PR_RST} in %{$limegreen%}%~
$ '

YESSS! Terminal is fixed and now works fast. Now my OSX Terminal with zsh and oh-my-zsh no longer slow. Now it is super blazing fast. Less than 1 sec to open Terminal and see a beautiful prompt.

Now I add my brew packages back into the mix.

brew install zsh-completions geoip zsh-completions wget

And since I’m still training to be a Linux Superhero, I add zsh-autosuggestions

  1. Clone this repository somewhere on your machine. This guide will assume ~/.zsh/zsh-autosuggestions.
    git clone git:// ~/.zsh/zsh-autosuggestions
  2. Add the following to your .zshrc:
    source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh
  3. Now refresh your updated .zshrc in Terminal:
    source ~/.zshrc

And that’s it. Super fast OSX Terminal with zsh and oh-my-zsh. Time to be a Linux hero. Time for practice. Lots of practice.

I intend for this post to save you slow zsh Mac OSX Terminal users many hours of time and suffering.

I wonder if oh-my-zsh is going to fix this slow OSX Terminal with oh-my-zsh with some sort of theme standardization and theme warning label.
Leave your comments below.


Leave a comment