Practical differences between Bash and Zsh

Apple announced that macOS Catalina will use Zsh as the default shell instead of Bash. If you have been using Bash for years, you might wonder what actually changes. In practice, not much — but there are a few things worth knowing.

Why the switch?

The version of Bash that ships with macOS is stuck at 3.2 (from 2007) because newer versions use the GPLv3 licence, which Apple does not want to bundle. Zsh uses the MIT licence, so Apple can ship the latest version.

What stays the same

Most of your day-to-day commands work identically. cd, ls, grep, git, brew — all of that is unchanged. Simple shell scripts will run the same way in both.

What is different

FeatureBashZsh
Config file~/.bashrc / ~/.bash_profile~/.zshrc / ~/.zprofile
Tab completionBasicMuch more powerful out of the box
Glob patternsStandardExtended (e.g. **/*.txt works natively)
Prompt customisationPS1 variablePROMPT variable with more options
Spelling correctionNoBuilt-in (setopt CORRECT)
Plugin ecosystemLimitedOh My Zsh and others

What to do

If you have a ~/.bash_profile or ~/.bashrc, move your aliases and exports to ~/.zshrc. Most lines copy over without changes. If a script starts with #!/bin/bash, it will still run with Bash regardless of your default shell.

# check your current shell
echo $SHELL

For most people, the switch is painless. Zsh does everything Bash does and adds better tab completion and globbing on top.


Enjoyed this post?

Well, you could share the post with others, follow me with RSS Feeds and/or send me a comment via email.


Tags

Category:

Year: