Oh-my-zsh is becoming unbearably slow…
Here are some approaches to speed up it.
Intro
I’m not a computer science expert, so I always choose to bear with the small issues happing on my laptop. My personal as well as working laptops are all Mac. And I use iTerm2 and Oh-My-Zsh to replace the default Terminal. For the zsh theme, I recommend mrtazz
.
One of the costs of using Oh-my-zsh is that the startup times are slow. That’s what everyone says.
But recently, I am getting more and more frustrated by the slow startup times. By searching online, I found this tutorial really helpful.
The following are the steps I took to improve my oh-my-zsh experience:
Step 1: Benchmarking Current Performance
Let’s measure how long it takes to start a new shell session:
1 | $ /usr/bin/time zsh -i -c exit |
5.5 seconds??? That is not good at all.
Step 2: Check What Slows It Down
Now, please pay attention. Run the following command in your Terminal, and take note of the portion where the output pauses a bit.
1 | $ zsh -xv |
For my case, I found the portion for setting hadoop & hive
parameters, and also for setting up nvm
tend to get stuck for a while.
Step 3: Remove the Unnecessary Parts
As I don’t need hadoop
and nvm
that often, I decided to prevent them from auto-loading during starting up zsh.
So I made the following changes in my ~/.zshrc
file:
- Comment out the Hadoop Hive exports commands
1 | #hadoop & hive |
- Comment out the nvm loading command. Instead, create an alias for it so that I can easily load it when I need it.
1 | #nvm |
The End
That’s all~ Now let’s quite the Terminal and reopen it.
Test the time again:
1 | $ /usr/bin/time zsh -i -c exit |
Yeah.