Having your zsh slow to start is a pain, but here’s some quick and easy ways to find out why, with tools build in to zsh. TL;DR, it’s probably NVM.
Add this to the start of your .zshrc
file:
# zmodload zsh/zprof
then add this as the last line:
# zprof
and when you start your zsh session you’ll get a bunch of data on what’s making your startup slow.
For me it was nvm and it deciding what version to run, taking over 5 seconds to decide, when most of the time I don’t use or need nvm. I followed the advice from Aron Schueler over on hs blog and ended up with something like this, and a much faster startup time.
This is my “after” timing, I wasn’t going to write it up, I just Googled slow startup times for zsh and thought I’d write up what I found. Scott Spence also has some advice if your slowdowns don’t come from NVM.
Last login: Mon Jul 21 13:34:58 on ttys005
num calls time self name
-----------------------------------------------------------------------------------
1) 30 106.14 3.54 53.74% 66.24 2.21 33.54% _omz_source
2) 2 25.07 12.53 12.69% 25.07 12.53 12.69% compaudit
3) 1 19.24 19.24 9.74% 19.24 19.24 9.74% (anon) [/Users/stuart.grimshaw/.oh-my-zsh/plugins/emoji/emoji.plugin.zsh:14]
4) 1 35.30 35.30 17.87% 15.28 15.28 7.74% spaceship::core::load_sections
5) 1 35.61 35.61 18.03% 10.55 10.55 5.34% compinit