The Z shell (Zsh) is a Unix shell that can be used as an interactive login shell and as a powerful command interpreter for shell scripting.
Questions about the Unix shell zsh (Z shell). Tag with zsh-alias, zsh-completion and zshrc for questions about zsh aliasing, command completion and configuration respectively.
The Z shell can be used as an interactive login shell and as a powerful command interpreter for shell scripting. It can be thought of as an extended Bourne shell with a large number of improvements, including some features of bash, ksh, and tcsh. However, it does not provide compatibility with POSIX or other shells in its default operating mode.
Apple's macOS switched to Zsh as the default shell for new accounts in macOS Catalina (2019). Previously, the default interactive shell was Bash (which still remains available as an option, albeit at a rather dated version).
Origin
The first version of zsh was written by Paul Falstad in 1990 when he was a student at Princeton University.
Features
Features of note include:
- Programmable command line completion that can help the user type both options and arguments for most used commands, with out-of-the-box support for several hundred commands
- Sharing of command history among all running shells
- Extended file globbing allows file specification without needing to run an external program such as find
- Improved variable/array handling
- Editing of multi-line commands in a single buffer
- Spelling correction
- Various compatibility modes, e.g. zsh can pretend to be a Bourne shell when run as /bin/sh
- Themeable prompts, including the ability to put prompt information on the right side of the screen and have it auto-hide when typing a long command
- Loadable modules, providing among other things: full TCP and Unix domain socket controls, an FTP client, and extended math functions
- Fully customizable
Attesting to the sheer size of this shell is the famous first sentence of the shell's manual page, which reads "Because zsh contains many features, the zsh manual has been split into a number of sections", and then goes on to list seventeen items.
Documentation
- The Zsh web page index
- The Z-Shell Manual (PDF).
- zsh-lovers, "Tips, Tricks and Examples for the Z-Shell".
- Zsh wiki: has lots of well documented samples and code