Two shells sit on an island: The Bourne-again shell and the Z shell.
ποΈ They both lay claim to dominion of the command line beachβ¦ π
The Bourne-again shell has been around for a while but is far from outdated. It has received new additions since its early days as the Borne shell, when it was born. The Z shell is new and slick, though, and has lots of fans1. The Z sell can do almost everything the Bourne-again shell can do and more.
While they could be friends, these shells battle for dominion. So consumed by competition, what they donβt realise is that they are almost identical.
What are Bash and Zsh?
The Bourne-again shell (bash
) was created in 1989 by Brian Fox as a replacement for the earlier Bourne shell (sh), developed in 1979 by Stephen Bourne. Just like the super-bad action hunk Jason Bourne, the Bourne-again shell rose to command-line supremacy and earned its place as the default shell on most systems.
That was until the new kid arrived on the block. In 2019, the Z shell (zsh
) replaced bash
as the default shell on macOS. What does this mean for you? Firstly, no need to panic because these two shells are almost identical.
Zsh was born (not Bourne) in 1990, created by then-Princeton student Paul Falstad. Falstad named his shell after his professor Zhong Shao (sweet!). The zsh
shell was intended to be an expanded combination of two other shells, ksh and tcsh, which would combine user-friendly features such as extended spell checking and autocompletion alongside extended programming capacity. With almost all the features of bash
and more, zsh
is now considered one of the best command line shells (but the battle for the top spot is far from over).
π» So what can I do in zsh that I canβt do in bash?
1. Letβs start with a small one. Zsh does not recognise #
as a comment start. You need to specify this explicitly.
2. zsh
has autocorrection (like a shell Grammarly) built in - so if youβre half asleep and coding, it will help you out!
3. Similarly, while bash
and zsh
also have autocompletion, the zsh
autocompletion is considered richer and more accurate. Accessing autocompletion (via the Tab
key) in zsh
also produces a drop-down list of alternative files and folders you can access. Additionally, zsh
has autocompletion for Git too!
4. The fan club. zsh
has a serious fan club, which maintains and develops an enormous range of plugins (ever 250!), enabling users to super-personalise their environment with various fun features. You can find the nerds who run this here
credit: u/Argran
5. As an older shell, you can find more support and information for bash
online. However, much of this support will also apply to zsh
because of their similarities.
So why do we teach Bash and not Zsh?
bash
is a more universal shell and is a good place to start. Knowing bash
is also useful as it is still the default shell in several systems. But luckily, you can apply what you learn about bash
to get you started with zsh
.
Have a go for yourself! Most of the bash
commands you have learned will work on zsh
. Can you find any differences between these shells yourself? π
Footnotes
the fans: Oh My Zsh!β©οΈ