Zsh Shell Tutorial for Beginners | Introduction to Zsh on mac (Lesson 01)
Video: Zsh Shell Tutorial for Beginners | Introduction to Zsh on mac (Lesson 01) by Taught by Celeste AI - AI Coding Coach
Zsh Lesson 1: Your First Terminal Commands on macOS
whoami,date,cal,echo— the four "no-arg, just type and run" commands.manopens an interactive pager. Zsh is the default shell on macOS Catalina+; you're already in it.
If you've never used a terminal before, this is the orientation. Open Terminal.app (or iTerm, Warp, Ghostty — any terminal). You're at a prompt. Time to type.
whoami: the obvious one
whoami
# alice
Prints your username. Good first command — confirms the shell is alive and listening.
date: the current date and time
date
# Wed May 8 16:02:55 PST 2026
Date and time, in your locale's format. Useful for log timestamps:
echo "Started at: $(date)"
cal: a quick calendar
cal
# May 2026
# Su Mo Tu We Th Fr Sa
# 1 2
# 3 4 5 6 7 8 9
# 10 11 12 13 14 15 16
# ...
This month's calendar. cal 2026 for the whole year, cal 12 2025 for December 2025.
echo: print a line
echo Hello, World!
# Hello, World!
echo Welcome to Zsh Shell Scripting
# Welcome to Zsh Shell Scripting
echo args prints its arguments separated by spaces, then a newline. The most-used command in any shell.
Variable expansion: $VAR
The shell substitutes $VAR with the variable's value:
echo My shell is $SHELL
# My shell is /bin/zsh
echo Home: $HOME
# Home: /Users/alice
$SHELL, $HOME, $USER, $PATH are environment variables — set by macOS before you log in.
Arithmetic: $(( ... ))
echo 2 + 2 = $((2 + 2))
# 2 + 2 = 4
echo $((10 * 5))
# 50
$(( expr )) evaluates an arithmetic expression. Useful for quick math right at the prompt — no calculator needed.
Lesson 7 covers arithmetic in depth (operators, increment, etc.).
man: the manual
man ls
Opens the manual for ls in a pager. Inside the pager:
- SPACE — next page
- b — previous page
- / then text + Enter — search forward
- n — next match
- q — quit
Every Unix command has a man page. When in doubt:
man <command>
For a quick peek without paging:
man ls | head -20
whatis: one-line description
whatis ls
# ls(1) - list directory contents
whatis date
# date(1) - display or set date and time
whatis cal
# cal(1) - displays a calendar
whatis reads the one-line description from the man page. Faster than opening the full manual when you just want to know "what does this thing do?"
Why Zsh
macOS Catalina (2019) made Zsh the default shell, replacing Bash. Most of what you type works the same in either, but Zsh has nicer:
- Tab completion — context-aware, often suggests options.
- Globbing — more powerful patterns (
**/*.txtrecursive,^*.txtfor "not txt"). - Prompt customization — built-in escape codes for colors, git status, etc.
- Plugin ecosystem — Oh My Zsh, Prezto, Starship.
You can switch to Bash anytime (bash) if you need to. But for daily use, Zsh on macOS is the path of least resistance.
The prompt
You'll see something like:
alice@MacBook-Pro ~ %
Means: user alice, hostname MacBook-Pro, current directory ~ (home), prompt character %. Lesson 5 covers customizing this.
Editing what you type
- left/right arrows — move within the line.
- Ctrl-A — jump to start of line.
- Ctrl-E — jump to end.
- Ctrl-W — delete word backward.
- Ctrl-U — clear the line.
- up/down arrows — cycle through command history.
These work in almost every terminal app on macOS. They become muscle memory fast.
Tab completion
Start typing a command or path, hit Tab:
cd Doc<Tab> # → cd Documents/
ls /usr/lo<Tab> # → ls /usr/local/
If multiple options match, hit Tab again — Zsh shows a menu. Use arrows to pick.
This single feature saves more typing than anything else.
History
history # last 16 commands
history 1 # full history, numbered
!42 # rerun command 42
!! # rerun the previous command
sudo !! # rerun previous with sudo
History is stored in ~/.zsh_history. Survives across sessions (after configuring .zshrc, lesson 5).
A first session
Try this end-to-end:
whoami
date
cal
echo "Hello from $USER on $(date +%A)!"
echo $HOME
echo $((42 + 8))
man echo | head -10
The last line shows: command, run, then peek at its manual.
Common stumbles
Spaces matter. echo Hello world works; echo "Hello world" is identical. But MY_VAR=value (no spaces around =) is required for variable assignment — MY_VAR = value errors.
echo $undefined_var is silent. Empty string. To detect typos, use set -u in scripts (lesson 6).
man opens but I can't escape. Press q. Always q to quit pagers and vim.
Case matters. LS is not ls. macOS file systems are usually case-insensitive (so LS Documents finds the dir), but command names always need correct case.
Pasted command runs immediately. If a paste ends with a newline. Most terminals show "do you want to paste this?" for multi-line. Be careful with copy-paste from web.
What's next
Lesson 2: navigating the file system. cd, pwd, ls, path shortcuts.
Recap
whoami, date, cal, echo — minimal first commands. Variable expansion $VAR. Arithmetic $(( expr )). man <cmd> for the manual (q to quit, / to search, SPACE to page); whatis <cmd> for the one-liner. Zsh is the macOS default since Catalina; nicer than Bash for daily use. Tab completion saves keystrokes; arrow keys navigate history.
Next lesson: navigating the file system.