esc
Anthology / Yagnipedia / zsh

zsh

The Shell That Made the Prompt a Lifestyle
Technology · First observed 1990 (Paul Falstad, Princeton University — named after Yale professor Zhong Shao's login name, which is the most Unix origin story possible) · Severity: Personal — riclib's shell, because oh-my-zsh uses git to update itself and that is the correct amount of self-awareness for a shell framework

zsh (Z shell) is a Unix shell created by Paul Falstad in 1990 at Princeton University. It does everything Bash does, plus more. Better tab completion. Better globbing. Better parameter expansion. Better history. Better everything, if you are willing to configure it, and you will be willing, because configuring zsh is the activity that replaces writing code for the first month after you switch.

riclib uses zsh. Specifically, riclib uses zsh with oh-my-zsh, because oh-my-zsh uses git to update itself, and a shell framework that manages its own updates through the version control system it helps you interact with has achieved a level of self-referential elegance that justifies its existence regardless of any other feature.

“I switched to zsh for the tab completion. I stayed for oh-my-zsh. I stayed for oh-my-zsh because it uses git to update itself. A tool that uses the tool it configures to update itself is either beautiful recursion or a snake eating its tail, and I choose to see it as beautiful.”
— riclib, on why zsh

oh-my-zsh

oh-my-zsh is a community-driven framework for managing zsh configuration. It has themes. It has plugins. It has 2,000+ contributors, 170,000+ GitHub stars, and a plugin for every tool, language, and workflow a developer has ever used.

The plugins:

The typical oh-my-zsh user enables 15-20 plugins during the initial setup enthusiasm, discovers that the shell starts slowly, spends an evening debugging the startup time, disables 11 plugins, and settles on 4 that they actually use: git, docker, and two others they’ve forgotten are loaded but are afraid to remove in case something breaks.

“Oh-my-zsh has 300 plugins. I use 4. The other 296 exist so that during setup I can feel like I’m being thorough.”
The Caffeinated Squirrel, who spent an hour choosing a theme

The Prompt

The zsh prompt is where developers go to express themselves. This sounds like a joke. It is not a joke.

Bash users have a prompt: user@host:dir$. Functional. Informative. Plain. zsh users have a prompt that displays: the current directory with path segments in different colours, the git branch with dirty/clean indicators, the number of commits ahead and behind the remote, the kubernetes context, the AWS profile, the Python virtualenv, the Node version, the time, the exit code of the last command, and — in some configurations — the battery level, the weather, and a small emoji that changes based on whether the last command succeeded or failed.

This is not a prompt. This is a dashboard.

The dashboard is rendered by prompt themes — Powerlevel10k being the current favourite — that use asynchronous rendering, segment caching, and instant prompt technology to display this information without delaying the shell’s response time. The prompt renders in milliseconds. The prompt took hours to configure. The prompt displays information the developer looks at once per session and ignores thereafter, but removing it would feel wrong, like removing a painting from a wall: you don’t look at it every day, but the room would feel empty without it.

The macOS Switch

In 2019, Apple changed the default shell on macOS from Bash to zsh. This was not because zsh was better — though it was. This was because Bash had moved to GPLv3 with version 4.0, and Apple, which ships Bash with macOS, would not include GPLv3 software because GPLv3 requires source code distribution for linked works and Apple’s lawyers had opinions about this.

So macOS shipped Bash 3.2 (2007, the last GPLv2 version) for years, while Linux had Bash 5.x, and eventually Apple decided that shipping a fourteen-year-old shell was worse than switching to zsh, which uses the MIT license, which Apple’s lawyers did not have opinions about.

The result: millions of macOS developers were switched to zsh without asking, discovered oh-my-zsh within the week, and never went back.

Measured Characteristics

Year created:                            1990
Creator:                                 Paul Falstad (Princeton University)
Named after:                             Zhong Shao's login name (zsh)
riclib's shell:                          yes
Why:                                     oh-my-zsh uses git to update itself
oh-my-zsh plugins available:             300+
oh-my-zsh plugins riclib uses:           ~4
oh-my-zsh GitHub stars:                  170,000+
Time to configure the prompt:            1-4 hours
Time spent looking at the prompt after:  seconds per session
macOS default since:                     2019 (Catalina)
Reason for macOS switch:                 GPLv3 licensing (not quality)
Bash version Apple was shipping:         3.2 (from 2007, fourteen years old)
The prompt:                              a dashboard (that you configured once and never changed)
The update mechanism:                    git pull (beautiful recursion)

See Also