The Z shell (Zsh) is a Unix shell that can be used as an interactive login shell and as a command interpreter for shell scripting. Zsh is an extended Bourne shell with many improvements, including some features of Bash, ksh, and tcsh.
In June 2019, Apple announced that the forthcoming macOS Catalina (10.15) would adopt Zsh as the default shell, replacing Bash.
Features 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.
- The built-in
where
command. Works like thewhich
command but shows all locations of the target command in the directories specified in$PATH
rather than only the one that will be used. - Named directories. This allows the user to set up shortcuts such as
~mydir
, which then behave the way~
and~user
do.
With macOS Catalina, Apple is now using Zsh as the default shell. We love Zsh, but the trusty old Bash shell is still included with macOS, and you can quickly switch back to Bash if you prefer.
Zsh is only the default shell on newly created user accounts, so any existing accounts you have on an upgraded Mac will still use Bash by default unless you change it. Each user account has its own default shell preference.
From the Terminal
To change a user account’s default shell on macOS, simply run the chsh -s
(change shell) command in a Terminal window.
Change the default shell to Bash by running the following command:
chsh -s /bin/bash
You’ll have to enter your user account’s password. Finally, close the Terminal window and reopen it. You’ll be using Bash instead of Zsh.
Change the default shell back to Zsh by running this command:
chsh -s /bin/zsh
Enter your password when prompted. After you close the terminal window and reopen it, you’ll be using Zsh.
You can see a list of included shells you can select by running the following command:
cat /etc/shells