What is ZSH? The shell that makes your terminal smarter
Learn what ZSH is, how it differs from bash, how to install it, configure your .zshrc, and use plugins and themes without slowing down your terminal.
Beginner$ echo $SHELL▍If you’ve opened Terminal on a recent Mac, you’ve already used ZSH without noticing. It’s a shell, the program that reads what you type and asks the operating system to run it. Think of it as a waiter in a restaurant: it takes your order (the command) to the kitchen (the system) and brings back the result.
ZSH (Z shell) is compatible with most of what you’d do in bash, the most common shell on Linux, and adds extra features that make everyday work more comfortable. Since macOS Catalina, released in 2019, it has been the default shell on Macs. If the idea of a shell is still new to you, read what is a shell and shell scripting first.
What ZSH does differently
- Smarter Tab completion: besides completing file names, it shows the possible commands, subcommands (like
git sw<Tab>), and even flags, and pressing Tab again cycles through those options. Just turn on completion (see the.zshrcbelow). - Spelling correction: with the
CORRECToption on, if you typegti status, it asks whether you meantgit status. - Shared history: commands typed in one terminal tab can show up in the history of the other tabs.
- Powerful globbing: globbing means using wildcards like
*to select many files at once. In ZSH,ls **/*.mdlists every.mdfile in the current folder and all its subfolders, with no extra setup. - Themes and plugins: you can change the look of the prompt (the line shown before the cursor) and add extra features with plugins.
Checking and changing your shell
First, find out which shell you’re using:
# shows your default shell
echo $SHELL
# on Ubuntu/Debian, install zsh
sudo apt update
sudo apt install zsh
# confirm the installation
zsh --version
# set zsh as your default shell
chsh -s $(which zsh)
chsh (change shell) asks for your password and only takes effect at your next login: close the terminal (or log out and back in) to see the change. On macOS, ZSH is already installed. If you use Windows, you can follow this article inside WSL.
The first time, ZSH may open a setup wizard; choosing the option that creates a basic file is safe.
The .zshrc file
.zshrc is a text file in your home folder (~/.zshrc) that ZSH reads every time you open the terminal. It’s the shell’s “preferences file”; the dot at the start of the name marks a hidden file.
A small, commented example:
# ~/.zshrc
# History: keep up to 10,000 commands in ~/.zsh_history
HISTFILE=~/.zsh_history
HISTSIZE=10000
SAVEHIST=10000
setopt SHARE_HISTORY # share history between tabs
setopt HIST_IGNORE_DUPS # don't store the same command twice in a row
setopt CORRECT # suggest fixes for mistyped commands
# Turn on advanced completion
autoload -Uz compinit && compinit
# Aliases: nicknames for long commands
alias ll="ls -lah"
alias gs="git status"
# PATH: folders where the shell looks for programs
export PATH="$HOME/.local/bin:$PATH"
An alias is a nickname: typing ll now runs ls -lah. PATH is the list of folders where the shell looks for programs. After editing the file, apply the changes with source ~/.zshrc or open a new terminal.
Popular frameworks and tools
None of this is required, but these tools make life easier:
| Tool | What it is | Who it’s for |
|---|---|---|
| Oh My Zsh | Framework with hundreds of ready-made plugins and themes | People who want a quick start |
| Prezto | A leaner configuration framework | People who prefer something lighter |
| zinit / antidote | Plugin managers focused on speed | People who want fine-grained control |
| Starship | Customizable prompt that works across shells (ZSH, bash, fish) | People who switch shells or want a fast, good-looking prompt |
| Powerlevel10k | A very popular, fast prompt theme | Check its maintenance status in the repository first; it states limited support |
Plugins worth trying
- zsh-autosuggestions: as you type, it suggests a command from your history in gray. Press the right arrow to accept it.
- zsh-syntax-highlighting: colors the command green when it exists and red when it doesn’t, before you even press Enter.
- git (from Oh My Zsh): adds shortcuts like
gstforgit status(Oh My Zsh’s default theme is what shows your current branch in the prompt). If Git is still new to you, see what is Git and GitHub.
Installing Oh My Zsh safely
The official site (ohmyz.sh) suggests this command:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
It downloads a script from the internet and runs it immediately. It works, but it’s a risky habit: you’re running code you haven’t read. A safer approach is to download it, read it, and only then run it:
# 1. download the script to a file
curl -fsSL -o install-ohmyzsh.sh https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
# 2. read it calmly (press q to quit)
less install-ohmyzsh.sh
# 3. if everything looks fine, run it
sh install-ohmyzsh.sh
The installer backs up your current .zshrc before creating a new one. After that, plugins are enabled in the plugins=(git) line of .zshrc.
Keeping your terminal fast
Every plugin is code that runs each time you open the terminal. With too many of them, startup can take a few seconds. A few tips:
- Start with two or three plugins and only add more when you actually need them.
- Remove what you don’t use.
- To measure, run
time zsh -i -c exit: it opens and closes a ZSH session and shows how long it took.
Bash vs. ZSH
| Aspect | Bash | ZSH |
|---|---|---|
| Default on | Most Linux distributions | macOS (since Catalina) |
| Config file | ~/.bashrc |
~/.zshrc |
| Completion | Works well, but simpler | Cycles through options with Tab, completes subcommands and flags |
Recursive globbing (**) |
Must be enabled (shopt -s globstar) |
Works by default |
| Array indexes | Start at 0 | Start at 1 |
| Themes and plugins | Few, configured by hand | Large ecosystem (Oh My Zsh and others) |
| Scripts | De facto standard for scripts on Linux | Great for interactive use; for portable scripts, bash is more common |
Practical tip: use ZSH day to day and write scripts with #!/bin/bash when they need to run on servers.
Try it yourself
- Run
echo $SHELLand find out which shell you use today - Install ZSH (if needed) and make it your default shell with
chsh - Create two aliases in
~/.zshrcand apply them withsource ~/.zshrc - Test globbing with
ls **/*.mdin a folder that has subfolders - Download the Oh My Zsh installer, read the script with
less, and only then decide whether to run it - Measure startup time with
time zsh -i -c exitbefore and after adding plugins
Next steps
A good terminal works for you: configure it little by little and keep only what you actually use.