Modern shells are chock-full of great features and shortcuts, but even a small subset of these handy utilities can result in a sluggish and lackluster command line experience (CLX, maybe?).
nvm
script and a section has been added for that (see 2 Years Later…) and the TL;DR section has been updated to reflect these changes.Here's a nice one-liner I found somewhere and modified to test shell startups:
for i in $(seq 1 10); do /usr/bin/time zsh -li -c exit > /dev/null; done
It doesn't need to be perfectly exact, just way for me to see speed differences in iterative changes.
For changing directories, zsh
yells at me when I try to use a for-loop, so we'll have to settle for a single call. Again, it's still letting me see the deltas so I don't have an issue with it.
time ( cd /Users/mmanzi/Documents; cd ..; )
It can take over 2 full, human seconds for my shell to start, on a good day.
Here, starting zsh
after iTerm 2 and other shells were already running averaged just under 2 seconds per trial:
~ [14:03:29]
> $ for i in $(seq 1 10); do /usr/bin/time zsh -li -c exit > /dev/null; done
2.24 real 1.08 user 0.90 sys
1.85 real 1.03 user 0.83 sys
1.83 real 1.02 user 0.84 sys
1.94 real 1.07 user 0.90 sys
1.96 real 1.08 user 0.92 sys
1.86 real 1.03 user 0.85 sys
1.95 real 1.07 user 0.91 sys
2.00 real 1.08 user 0.96 sys
1.98 real 1.08 user 0.94 sys
1.92 real 1.05 user 0.89 sys
Average: 1.953 seconds
When running from sh
as the only logged-in shell to effectively cold start zsh
, the results were even worse:
Last login: Mon Nov 2 14:13:29 on ttys000
$ for i in $(seq 1 10); do /usr/bin/time zsh -li -c exit > /dev/null; done
2.03 real 1.09 user 0.97 sys
2.05 real 1.11 user 0.99 sys
2.40 real 1.25 user 1.16 sys
2.89 real 1.45 user 1.36 sys
2.74 real 1.32 user 1.34 sys
2.24 real 1.19 user 1.10 sys
2.01 real 1.09 user 0.95 sys
1.99 real 1.08 user 0.95 sys
2.02 real 1.08 user 0.95 sys
1.96 real 1.07 user 0.93 sys
Average: 2.233 seconds
Some great posts and blogs that are going to jump start what I'm doing—not trying to reinvent the wheel here.