# Setup: The Terminal on a Mac

Open the Terminal app, meet zsh, the shell it opens, then add Homebrew, bash 5 and bats, so every script and exercise check in this course runs on your Mac.

Novice · Unix · Linux · Updated November 10, 2026

## After this lesson you can

- Open the Terminal app on a Mac and recognize zsh's % prompt
- Choose the Homebrew commands that add bash 5 and bats to a Mac, and check each one with --version

## Key takeaways

- The Terminal app is in Applications, then Utilities. Cmd+Space, then typing Terminal, is the fastest way to open it.
- A Mac's Terminal opens zsh, whose prompt ends in %. You type this course's commands into zsh; where it differs from bash, a lesson says so.
- Homebrew is a package manager for the Mac. brew install adds command-line tools by name.
- macOS comes with bash 3.2, from 2006. brew install bash adds bash 5 for your scripts, and bats-core runs the exercise checks.

A class says "open a terminal and run…", a tutorial starts with a command, and you're on a Mac. Good news: the terminal is already on your computer, and so is a shell. This lesson opens it, then adds three free tools the course uses, in about twenty minutes, once. (On Linux or Windows? *Setup: The Terminal on Linux* or *Setup: The Terminal on Windows* is your lesson instead.)

## Open the Terminal app

Press **Cmd+Space** to open Spotlight, type `Terminal`, and press Enter. You can also find it in Finder, under **Applications**, then **Utilities**.

You'll open it often, so keep it in the Dock: while it's open, Control-click its icon in the Dock, then choose **Options**, then **Keep in Dock**.

![The Terminal app on a Mac, newly opened: a window with one line of text, the user name, the computer's name and a ~, ending in a % sign with the cursor after it](https://www.ask-codey.com/lessons/TODO)

## zsh, the shell your Mac opens

The window shows one line, something like `sam@Sams-MacBook-Air ~ %`: your user name, your computer's name, `~` (read "tilde", your home folder) and a `%`. That line is the **prompt**, and the `%` means "ready: type a command".

The program that reads what you type is called a **shell**, and a Mac's is **zsh** (read "zee shell"), the default since 2019. zsh and bash are close cousins: nearly every command in this course works the same in both, and where zsh differs, the lesson has a short note. You don't need to change anything. To see your shell's name, type this and press Enter:

```bash
echo $SHELL
```

It prints `/bin/zsh`. (`$SHELL` is read "the value of SHELL"; *Shell, Terminal, Prompt* explains the three words.)

## Homebrew: installing tools by name

macOS has no built-in way to add command-line tools. **Homebrew** is the free **package manager** most Mac developers use: `brew install`, followed by a tool's name, downloads it and sets it up.

Its official site, [brew.sh](https://brew.sh), shows one line to copy into your terminal. Before you press Enter, know what it does: it installs software, so it asks for your Mac's password, the one you sign in with. Nothing shows on the screen while you type it; type it anyway and press Enter. It may also offer to install Apple's Command Line Tools; say yes. It takes a few minutes.

```bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```

When it finishes, read its last lines. If they include **Next steps** with a few commands (they do on Macs with Apple chips), those commands let your terminal find `brew`: copy them from your own screen and run them. Then check:

```bash
brew --version
```

It prints `Homebrew` and a version number. If it says `command not found` instead, the Next steps lines haven't run yet. A good habit for life: copy installer lines only from the tool's own website.

## bash 5 for your scripts, and bats

Your Mac has bash too, but an old one. Type `bash --version`, and its first line says version 3.2.57: bash 3.2 came out in 2006, and Apple stopped updating it when bash's license changed. This course's scripts use features added since then, so add bash 5, along with **bats-core**, the program that runs the exercise checks:

```bash
brew install bash bats-core
```

Close the Terminal window, open a new one, and check both:

```bash
bash --version
bats --version
```

The first line of `bash --version` now says version 5.3 or newer, and `bats --version` prints `Bats` and a version number, such as `Bats 1.14.0`.

Your Terminal still opens zsh, and that's what you want. You type commands in zsh, and every script in this course starts with a line, `#!/usr/bin/env bash`, that runs it in bash 5. Leave your Mac's default shell as it is.

## Make your practice folder

Every lesson works in one practice folder, `terminal-practice`, in your home folder, so nothing you try touches your real files. Make it, go into it, and ask where you are:

```bash
mkdir -p ~/terminal-practice
cd ~/terminal-practice
pwd
```

`pwd` prints `/Users/`, your user name and `/terminal-practice`: for Sam, `/Users/sam/terminal-practice`. `mkdir` makes a folder (Module 2 covers it), `cd` moves you into it, and `pwd` says where you are (both are in the next chapter). Now type `open .` and Finder opens the same folder: two doors into one place.

## Check yourself

2 questions to try on the lesson page.

## So what

Your Mac now has everything this course uses: the Terminal and zsh for typing commands, Homebrew for installing tools, bash 5 for scripts and bats for exercise checks. You set it up once, and it's ready for every lesson.

## Key terms

- [Terminal](https://www.ask-codey.com/glossary/terminal)
- [zsh](https://www.ask-codey.com/glossary/zsh)
- [Homebrew](https://www.ask-codey.com/glossary/homebrew)
- [Package Manager](https://www.ask-codey.com/glossary/package-manager)
- [Bash](https://www.ask-codey.com/glossary/bash)

## Cheat sheets

- [Setup: The Terminal on a Mac](https://www.ask-codey.com/cheat-sheets/bash-setup-macos-cheat-sheet)

## Related

- [Shell, Terminal, Prompt](https://www.ask-codey.com/lessons/bash-shell-terminal-prompt)
- [Exercise: Your Practice Folder](https://www.ask-codey.com/lessons/exercise-bash-your-practice-folder)

Source: https://www.ask-codey.com/lessons/bash-setup-macos
