slows down zsh startup time considerably
Created by: sodiumjoe
First off, thanks for autojump
!
➤ /usr/bin/time /bin/zsh -i -c exit
0.50 real 0.37 user 0.11 sys
and with autojump commented out of my .zshrc
:
➤ /usr/bin/time /bin/zsh -i -c exit
0.13 real 0.09 user 0.02 sys
most of the time looks like it's spent calling brew
and brew --prefix
, so I tried:
.zshrc
# [[ -s $(brew --prefix)/etc/profile.d/autojump.sh ]] && . $(brew --prefix)/etc/profile.d/autojump.sh
[[ -s /usr/local/etc/profile.d/autojump.sh ]] && . /usr/local/etc/profile.d/autojump.sh
and in /usr/local/share/autojump/autojump.zsh
(which is $(brew --prefix)/etc/profile.d/autojump.sh
):
# set homebrew installation paths
# if command -v brew &>/dev/null && [[ -d "$(brew --prefix)/share/zsh/site-functions" ]]; then
# fpath=("$(brew --prefix)/share/zsh/site-functions" ${fpath})
# fi
if [[ -d "/usr/local/share/zsh/site-functions" ]]; then
fpath=("/usr/local/share/zsh/site-functions" ${fpath})
fi
and now:
➤ /usr/bin/time /bin/zsh -i -c exit
0.13 real 0.09 user 0.03 sys
seems like you could:
- set an env var on the first
brew --prefix
- let me set the env var myself and skip the
brew --prefix
entirely - skip the
command -v brew &>/dev/null
since presumably it's redundant withbrew --prefix