Oh-my-SLOW-Zsh
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.
zprof
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
https://gist.github.com/ctechols/ca1035271ad134841284
As aksh1618 indicated, I edited oh-my-
# 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-
find $HOME -maxdepth 1 -iname '.zcompdump*' -mtime 1 -delete | grep -q "." && source $HOME/.zshrc
As aksh1618, this will make oh-my-
Output of Zsh’s startup via zprof |
I hope it helps you to reduce your terminal’s startup time…