How to profile the `zsh` start time
If your terminal is slow to open, you can profile zsh startup to identify what’s causing the delay and optimize your configuration.
Quick timing check:
time zsh -i -c exit
This creates a temporary zsh subshell and shows total startup time.
Detailed profiling:
Add these lines to your ~/.zshrc:
# At the top of the file
zmodload zsh/zprof
# ... rest of your config ...
# At the bottom of the file
zprof
The built-in profiler will output timing data showing “num calls, time, self, and name” for each function, revealing which processes are slowest.
Common culprits:
Package managers often cause startup delays:
- nvm (Node Version Manager)
- pyenv (Python version management)
- conda (Python environment management)
Example:
One developer found that conda initialization was responsible for 4+ seconds of a 4.6-second startup time. Commenting out the conda block reduced startup to ~1 second.
Fix slow startup:
- Run
zprofto identify slow processes - Disable or lazy-load unnecessary initialization code
- Consider using alternatives like
zsh-deferfor non-critical plugins - Remove tools you don’t actively use