Zsh being a pain

I love Zsh and the features it comes with - but overtime it had become really slow. I was spending upto 5 seconds for the prompt to show up, something had to change.

Creating this blog so I can remember what I did to fix it.

Diagnosing the problem

I found that zsh comes with a profiler, which can be enabled quite easily.

At the top of your zshrc, add zmodload zsh/zprof and at the bottom of your zshrc, add zprof.

The lines in between define the scope of the profiler.

After restarting the terminal, I was seeing nvm taking a massive chunk of the time (its always JS).

Git was another culprit. While the bootup in zshrc wasn't bad, working with repos that had big files was making it really slow.

Fixes

Nvm can be replaced with fnm which is a lot faster, or you can lazy load the nvm plugin.

plugins+=(nvm)
zstyle ':omz:plugins:nvm' lazy yes

For git, remove dirty checking from the prompt.

git config --global --add oh-my-zsh.hide-status 1
git config --global --add oh-my-zsh.hide-dirty 1