zsh (Z Shell) is a powerful shell that is commonly used on macOS and other Unix-like operating systems (including Linux). It is a versatile and highly customizable shell that provides a number of features and options that make it a popular choice among power users and system administrators. In this article, we will introduce the basics of
zsh and show you how to get started with this powerful shell.
What is zsh?
zsh is a Unix shell that provides a command-line interface for interacting with the operating system. It is a powerful tool for performing a wide range of tasks, from basic file management to complex system administration.
zsh is known for its features, such as command line completion, history, and advanced scripting capabilities, which make it a popular choice for both novice and advanced users.
zsh is similar to other shells, such as
bash, but provides a number of additional features and options that make it a more powerful and flexible shell. For example,
zsh provides a rich scripting language that can be used to automate tasks and perform complex operations, as well as a large number of built-in commands and options that provide basic functionality and customization.
Paul Falstad, while a student at Princeton University, wrote the first version of Zsh in 1990. The name Zsh is derived from the login-id of Yale professor Zhong Shao, who was then serving as a teaching assistant at Princeton University. Falstad regarded Shao’s login-id as an appropriate moniker for a shell and thus named his creation Zsh.
Initially, Zsh was intended to be a subset of csh for the Commodore Amiga. However, as development progressed, the scope of Zsh expanded significantly beyond its original purpose. By the time version 1.0 was released in 1990, the aim of Zsh was to provide a cross between the functionality of ksh and tcsh. This new shell aimed to provide a powerful “command and programming language” that was well-designed and logical, like ksh, yet also user-friendly, like tcsh.
Zsh was designed to include features that were deemed “probably too weird to make it into an AT&T product.” These features include spell checking, login/logout watching, and termcap support. The result is a shell that provides a powerful and versatile environment for users who demand both functionality and ease-of-use.
In 2019, macOS Catalina adopted Zsh as the default login shell, replacing the GPLv2 licensed version of Bash, and when Bash is run interactively on Catalina, a warning is shown by default.
The default interactive shell is now zsh.
To update your account to use zsh, please run
chsh -s /bin/zsh.
For more details, please visit https://support.apple.com/kb/HT208050.
- Command line editing:
- programmable completion: incorporates the ability to use the full power of zsh’s globbing and shell programming features,
- multi-line commands editable as a single buffer (even files!),
- variable editing (vared),
- command buffer stack,
- print text straight into the buffer for immediate editing (print -z),
- execution of unbound commands,
- menu completion in two flavours,
- variable, editing function and option name completion,
- inline expansion of variables and history commands.
- Globbing — extremely powerful, including:
- recursive globbing (cf. find),
- file attribute qualifiers (size, type, etc. also cf. find),
- full alternation and negation of patterns.
- Handling of multiple redirections (simpler than tee).
- Large number of options for tailoring.
- Path expansion (=foo -> /usr/bin/foo).
- Adaptable messages for spelling, watch, time as well as prompt (including conditional expressions).
- Named directories.
- Comprehensive integer and floating point arithmetic.
- Manipulation of arrays (including reverse subscripting).
- Associative arrays (key-to-value hashes)
- Spelling correction.
To learn more about zsh and its features, try the User’s Guide to the Z-Shell.
Logo: Justin Dorfman, CC BY-SA 4.0 https://creativecommons.org/licenses/by-sa/4.0, via Wikimedia Commons.
Gladstone is a tech virtuoso, boasting a dynamic 25-year journey through the digital landscape. A maestro of code, he has engineered cutting-edge software, orchestrated high-performing teams, and masterminded robust system architectures. His experience covers large-scale systems, as well as the intricacies of embedded systems and microcontrollers. A proud alumnus of a prestigious British institution, he wields a computer-science-related honours degree.