Speed up opening new zsh sessions

I noticed that it got slower than before to open new zsh session. I use zsh on tmux. I shorten the time to open new session with steps following.

Installed starship

I used to use oh-my-zsh with spaceship-prompt. I changed spaceship-prompt to starship.

Installed with Homeberw

brew install starship

And added init command to ~/.zshrc

# ~/.zshrc

eval "$(starship init zsh)"

Quit using Oh My Zsh

After I installed starship, I found it satisfies what I want. I want to see which git branch I’m on, which versions of language I’m using. Starship covered them.

Omit $(…) from .zshrc

To run commands in .zshrc is not very fast. For example, $(brew --prefix). It is not always very slow but some commands are slow. I expanded direct paths and hardcoded them.

Omit double quotations from .zshrc

I’m actually not sure what the reason is. But somehow PATH="...:$PATH" are sometimes slow. Probably because my $PATH is fat, so expanding them take long. I omit " as many as possible.

Modified .tmux.conf

When I started using tmux, I copied someone’s .tmux.conf. It worked well, so I just kept using it. But whenever I opened a new pane or window, it takes some time.

There was such a line in order to load shell configuration. Actually it was not necessary. Most times, I don’t update .zshrc, so I don’t need to load configuration each time.

I deleted this line.

set -g default-command "${SHELL} -l"

Conclusion

Hope it helps someone.

Contents