I want my shell to start up in less than 200 milliseconds. Ideally, even faster
than that, but that’s my upper boundary.
Things I’ve noticed causing problems:
- Scanning ~/mail and all of it’s subfolders to set $MAILDIR so that my shell
can notify me of new emails - Executing
keychainto launch an ssh agent - Running
rbenv rehashon shell launch, which is too often - Iterating through a bunch of extra directories to build
$PATH.- I also was doing a lot of extra work that zsh can do for me by using filename globing
compinitis really slow.- Shelling out to check what OS I was running on (OS Detection can replace that)
A lot of things can be delayed from running synchronously, to be ran during the
first precmd.
Useful links
- https://esham.io/2018/02/zsh-profiling
- https://xebia.com/blog/profiling-zsh-shell-scripts/
- https://stevenvanbael.com/profiling-zsh-startup
- https://www.bigbinary.com/blog/zsh-profiling
- https://notes.billmill.org/computer_usage/zsh/profiling_zsh_startup.html
- https://www.dribin.org/dave/blog/archives/2024/01/01/zsh-performance/