I am writing this post to show how to debug slow zsh…

first thing is to show how slow your zsh is. For that lets run 10 times and see how long does it take to get up and running…

for i in $(seq 1 10); do /usr/bin/time $SHELL -i -c exit; done`

Obviously, I assume your default $SHELL is set as Zsh…

Okay, we observed it takes some time with the previous command. Let’s do a bit more debugging. Let’s run ZSH in debug mode:

zsh -xv

This will give you more information – it shows the process as the package loaded. So in my case, the rbenv plugin was extremely slow. As I don’t use that plugin so I simply disabled by removing the plugin from the plugin section of file ~/.zshrc

I think you should reduce start-up time by using the described methodology. However, in order to get more fine-grained approach you can add the following link at the beginning of the very same file ~.zshrc

zmodload zsh/zprof

And add the next line add the end of the same file.


Close and save and get a new terminal you should learn more details with. Take your time to analyse the output…

Output of ZSH’s startup via zprof

Again in my case, I can see compinit takes so much time to load. For that I did a bit of googling and reached the following url:


As aksh1618 indicated, I edited oh-my-zsh.sh file what is stored in ~/.oh-my-zsh/oh-my-zsh.sh. First I found the following line:

# Else, enable and cache completions to the desired file. else compinit -d "${ZSH_COMPDUMP}" fi else compinit -i -d "${ZSH_COMPDUMP}" fi

And changed to

# Else, enable and cache completions to the desired file. else compinit -C -d "${ZSH_COMPDUMP}" fi else compinit -C -d "${ZSH_COMPDUMP}" fi

Moreover, add the following line to ~/.oh-my-zsh/oh-my-zsh.sh

find $HOME -maxdepth 1 -iname '.zcompdump*' -mtime 1 -delete | grep -q "." && source $HOME/.zshrc

As aksh1618, this will make oh-my-zsh.sh recreate any compdump older than a day. In my case, you can see the startup performance improved (check compinit). After your debug finished, you can remove related zprof lines (at the beginning/end your ~.zshrc) in order to stop printing debug information.

Output of Zsh’s startup via zprof

I hope it helps you to reduce your terminal’s startup time…