I spent some time figuring out why my Zsh startup time became so slow over time. Initially I thought about compinit
, and I added this fix mentioned everywhere on the internet (read zcompdump
once per day):
# autoload -U compinit && compinit
autoload -Uz compinit
if [ $(date +'%j') != $(stat -f '%Sm' -t '%j' ~/.config/zsh/.zcompdump) ]; then
compinit
else
compinit -C
fi
This helped, but the real culprint was NVM which considerably slows down Zsh startup with its loading script nvm.sh
. I use the following trick. In retrospect, compinit
isn’t accounting for that much time when checked agaisnt zprof
, but Zsh now starts like a breeze again:
~/.config/zsh
» time zsh -i -c exit
Saving session...completed.
zsh -i -c exit 0,03s user 0,03s system 90% cpu 0,073 total