The Z Shell (Zsh) on macOS Tahoe
As of macOS Tahoe, the default shell for the terminal is Zsh (Z shell). It replaces Bash, offering a more modern, feature-rich command-line experience out of the box.
Why Zsh?
Zsh is highly compatible with Bash but includes improvements that make interactive use much friendlier.
1. Intelligent Tab Completion
Zsh's tab completion is context-aware.
- Type
cd Doand pressTab-> Zsh completes toDocuments/. - Type
git aand pressTab-> Zsh suggestsadd,apply,archive, etc. - It can even navigate through options using the arrow keys after pressing Tab.
2. Spelling Correction
If you make a minor typo, Zsh often catches it.
- Typing
gut statusinstead ofgit statusmight prompt:zsh: correct 'gut' to 'git' [nyae]?
3. Path Expansion
You don't always need to type full paths.
- Typing
cd /u/lo/biand pressingTabcan expand to/usr/local/bin.
Basic Shortcuts
- Ctrl + U: Clear the current line.
- Ctrl + A: Move cursor to the beginning of the line.
- Ctrl + E: Move cursor to the end of the line.
- Ctrl + R: Search through command history.
Next Steps
Once you are comfortable with the basics of Zsh, you can start customizing it to fit your workflow.
- Configuration: Learn how to edit your
.zshrcfile, create aliases, and customize your prompt in the Advanced Zsh Configuration guide. - Scripting: Zsh is also a powerful scripting language. See Getting Started with macOS Tahoe for a basic scripting example.