zsh の起動の遅さに絶望して色々とゴソゴソ


単刀直入に。

before ~/.zshrc :

export PATH="$PATH:$(brew --prefix coreutils)/libexec/gnubin"
export CFLAGS="-I$(brew --prefix readline)/include -I$(brew --prefix openssl)/include -I$(xcrun --show-sdk-path)/usr/include"
export LDFLAGS="-L$(brew --prefix readline)/lib -L$(brew --prefix openssl)/lib"

この3行が活きていた頃、

$ time ( zsh -i -c exit )
( zsh -i -c exit; )  3.62s user 2.59s system 44% cpu 14.076 total
$

after ~/.zshrc:

こう書き換えて計測

#export PATH="$PATH:$(brew --prefix coreutils)/libexec/gnubin"
export PATH="$PATH:/usr/local/opt/coreutils/libexec/gnubin"
#export CFLAGS="-I$(brew --prefix readline)/include -I$(brew --prefix openssl)/include -I$(xcrun --show-sdk-path)/usr/include"
export CFLAGS="-I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include"
#export LDFLAGS="-L$(brew --prefix readline)/lib -L$(brew --prefix openssl)/lib"
export LDFLAGS="-L/usr/local/opt/readline/lib -L/usr/local/opt/openssl/lib"
$ time ( zsh -i -c exit )
( zsh -i -c exit; )  0.17s user 0.24s system 22% cpu 1.821 total
$

驚愕。
検索ヒット用に、zsh 起動 遅い 改善 brew を書いておきます。