ZSH takes about a second and a half from creating a new terminal window to being ready. I'm pretty sure that the culprit is compinit.

I haven't been able to find good documentation on compinit, but it looks like it should be caching all of the necessary things in some file like .zcompdump.

Any tricks on speeding it up?


oh-my-zsh was taking about 1.5 seconds to start up on my laptop. I wrote up some of the steps I took to get that down to about 0.25 seconds.

Another kind soul summarized the steps required to integrate my changes into your copy of oh-my-zsh.

The biggest problem is that compinit was being called a whole bunch of extra times instead of just one time after the fpath was completely defined. I made those changes on my branch of oh-my-zsh on github. The changes have been discussed on github and they seem to be working well for a few people. Hopefully the changes will be merged into oh-my-zsh in the near future.

  • 4
    For future readers, I believe all these changes have now been merged upstream. – Michael Mior May 12 '12 at 23:41
  • 1
    Changes may have been moved upstream, but removing Git from plugins has helped me substantially. – kylehotchkiss Jun 15 '12 at 12:57

While ZSH has it's own fair-share of slowdowns, if you find the terminal window blank for a few moments before you see the Last Login: line, you are going to need to clear your log files to see speed improvements. This is still an issue as of OSX Lion and will need to be done every several months. Lame, I know.

The command is:

sudo rm -rf /private/var/log/asl/*.asl

Of course, you need to read this article beforehand and so you know exactly what is going on, because running anything that says sudo rm needs to be thought about. I only put this here because your use of ZSH proves your competence with the command line to start.

  • 1
    Thanks, such a simple solution for something that's been plaguing me for so long! – Dean Jun 27 '13 at 15:35
  • 7
    I'd recommend not using -r since no directories are involved and it sn't needed. Omitting it leads to less tears if someone types sudo rm -rf / private/var/log/asl*.asl (space before private) by mistake. – Dean Jun 27 '13 at 15:39
  • 1
    Or even more foolproof, cd /private/var/log/asl then rm -f *.asl. Also for the record, this answer saved me from a startup time that was approaching 10 seconds, thanks a lot! – Garrett Disco May 12 '16 at 22:19
  • 1
    Worked for me! BTW trash /private/var/log/asl*.asl. trash will need to be installed, of course. brew install trash – Mike D Jan 16 '17 at 13:26

My biggest improvement has come from removing items from the plugin=() section. The 'github' and 'brew' plugins are very slow to load.

I also removed hub which I had aliased togitand that sped up the prompt as well.

I've been using '/usr/bin/time zsh -i -c exit' to record the startup times, however compinit doesn't appear to make a big enough difference for me.

It'd be great to hear what others are doing to speed it up.

  • 1
    Removing the github and brew plugins solved my problem immediately. – Peter Niederwieser Nov 15 '11 at 3:02
  • git and brew plugins are quite essential to me. By removing ruby plugin solved my problem. Thanks. – Ivan Z. G. Xiao Mar 19 '12 at 17:30

Are you using the pre-installed /bin/zsh or another one? I ask, because the zsh I have installed through fink starts terribly slow due its inclusion of zsh templates, while the vanilla starts right up.

Does running with an explicit dumpfile (compinit -d dumpfile) make it go faster? The man page states that

The next invocation of compinit will read the dumped file instead of performing a full initialization.

  • 2
    I am using Oh My Zsh (which I believe uses the default /bin/zsh). When I disable loading all of Oh My Zsh's plugins and whatnot, it loads up really quickly, but I think in that case compinit is never called. When I manually call compinit it takes a little while. Maybe it's just because Oh My Zsh adds so many bindings to compinit? – Eli Jan 24 '11 at 17:16

Now oh-my-zsh checks special git configuration option oh-my-zsh.hide-status before querying status. So run

git config oh-my-zsh.hide-status 1

on problematic repository.

  • for me I had to disable the git plugin in .zshrc. I am currently facing issues with slow internet response, which made zsh slow – Paschalis Aug 12 '16 at 2:02

Zsh on its own starts up in around 0.1 second for me, which is plenty good enough. I just noticed as I got near the 50,000 command history mark that it became more like 3 seconds to load up the first prompt.

I dunno how you guys are finding all these other reasons for slow startup, but mine was exactly what my first guess was. I did a mv ~/.zsh_history zsh_history_backup and bam, 3 second startup is now 0.1 second startup. Curiously, /usr/bin/time /bin/zsh -i -c exit fails to capture the time it takes to load in the history.

If you don't have tens of thousands of commands in your zsh history, though, then this isn't it. My ~/.zsh_history measured 1.8MB. Its very possible to accidentally paste a large chunk of stuff as a command into a terminal, this will also bloat history up right quick (though this is something very much to avoid doing as it can obviously be extremely destructive).

  • This is the answer. If haven't done anything fancy (a lot of plugins and addons) with oh-my-zsh, then I guarantee it's because of the history log. The change is immediate. – Sebastialonso Nov 16 '16 at 17:43

I was using the theme "af-magic"

Switching to "muse" solved the issue.

Edit ~/.zshrc and modify that line:

  • thanks for the answer, I found changing from af-magic to something else has solved for the problem. Interestingly restoring back af-magic still works great. not sure what went on under the hood. – sarat Jan 22 '16 at 5:11

I have really great speed improvements after clearing ~/.oh-my-zsh/plugins/ directory. There was many unused plugins inside it.


Add the following to your ~/.zshenv


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.