Speeding up Oh-my-zsh
Today I read a very interesting article about speeding up Oh-my-zsh. So, I tried to profile my own startup times and I discovered that:
- Zsh start time was about 500ms
- Bash start time is less than 10ms
- Zsh (without config) start time is less than 10ms
Most of startup time was spent loading 3 plugins that I regularly use:
emacs
, which provides handy aliases to interact with Emacs daemon. I was surprised this plugin was slow because it just defines a bunch of aliases. It turns out that it was spending 50+ ms checking Emacs' version (by starting up Emacs every time). I sped it up considerably by instead checkingemacsclient
version. PR submitted.kubectl
, which provides aliases and completion forkubectl
. It turns out that it was spending 200+ ms to generate the completion script usingkubectl completion zsh
every single time. I sped it up by caching the completion script, that is not subject to change very often. PR submitted.virtualenvwrapper
, which sourcesvirtualenvwrapper.sh
and little more. Virtualenvwrapper also supports a "lazy" version of its script, so I sped up startup times by preferring the "lazy" script to the "eager" one. PR submitted.
I hope the above 3 PRs will be approved and merged!