What is Zsh? Should You Use it?
Zsh has become so popular lately that Apple made it the default choice on macOS.
You probably already know that there are various shells available in Linux/Unix. Bash is the most popular and the default shell on most Linux distributions.
Another popular shell is Zsh. It is powerful and it is also the default Shell in macOS.
Now, the questions comes, what features make Zsh a popular choice and should you even bother to use it?
Let me answer that.
What is Zsh?
The "Z shell" was initially created by Paul Falstad when he was a student at Princetown University. Zsh incorporated many of the useful features present in other popular Shells like the Bourne-Again Shell (Bash), the Korn Shell (ksh), C-shell (csh), and tcsh. Therefore, Zsh was designed to offer some level of compatibility with those shells, allowing a higher user adoption.
Nowadays Zsh is a big open source project (not maintained Paul Falstad) with a large community of users and contributors, and since 2019 it's been the default Shell for Apple's macOS.
The differences between Bash and Zsh?
Nowadays, the active development of both open source projects is keeping both shells close to each other in terms of general features and functionality, but there are a few small differences on how to do certain things. Zsh is more powerful and customizable by default, while Bash may require some extra scripts (plugins) to achieve some things.
On a wider view, the main features that make Zsh shine over Bash are:
Zsh has more advanced features shipped in.
Auto-completion works faster and better in Zsh. In bash, the tab completion works by matching the term from the beginning (mn will match mnt but not findmnt). In Zsh, it could show results even if the term is in the middle.
In Zsh, commands history is shared across shells, which improves auto-completion's user experience.
Zsh also has auto-correction feature inbuilt. If you type too fast and make a typo, it may suggest an alternative correct command.
Zsh is more configurable and has more options to build fancy user prompts.
Parameter expansion in Zsh is more powerful than in Bash.
Zsh has plenty of plugins, themes and frameworks avilable, like the popular Oh My Zsh. It helps you get a fancy looking terminal with useful features.
Should you use Zsh?
Zsh has proven to be a powerful and fast shell, easily customizable, allowing the user to have a fancy and user-friendly CLI easily set up for daily use.
If you are a software developer or do any other kind of activity that requires you to use the CLI often on your own computer, Zsh seems to be a good choice to improve your general experience. This is, specially if you are willing to spend some time exploring it.
Should I Abandon Bash?
Bash isn't going anywhere and that's a fact! It is the standard shell embedded in most Linux distributions, which means, most of the servers, containers, virtual machines, and cloud instances around the world.
Regarding scripting, unless you have a very specific use, you'd probably be better writing bash scripts aiming for consistency around systems.
You may use Zsh in your main computer but don't think you won't touch Bash anymore, Bash scripting will still be a safe choice for years to come.
Why is it Default on macOS?
Besides Zsh being a great shell with nice features, the answer to the question is all about software licenses.
Before the switch to Zsh, for many years MacOS was delivering as the default shell Bash in its outdated version v3.2 (released in 2007!) which was the last version licensed under GPLv2. After 3.2, the newer versions of Bash are licensed under GPLv3, a license that seems to be unacceptable enough for Apple.
After more than a decade of delivering an outdated shell as default, Apple decides to deal with this issue and move to Zsh which is licensed under the MIT license.
Conclusion
Zsh may improve your CLI experience in your main computer, and it's a perfect choice for beginners since some frameworks make it shine with a simple install.
Bash is a good choice for scripting, also being comfortable with standard Bash installation may be very useful for someone that deals with DevOps, System Administration, Cloud Computing, and Containers, since it is the default shell for most Linux distributions.
If you want to try, install Zsh, switch to the Z shell and explore it. If you find it awesome, you may even make it the default shell.
Author info: Jonas B. Rossi is a System Developer and Analyst who loves to share tips on Linux, Vim and the CLI.
LHB Community is made of readers like you who like to contribute to the portal by writing helpful Linux tutorials.