Skip to content

Terminal basics: iTerm2 + Homebrew + Node.js

Learn the Mac terminal from scratch — once you know the basics, installing Claude Code is a single command.

What is a terminal

The terminal is a text-based interface that lets you control your computer by typing commands. The Terminal app that ships with macOS works fine, but iTerm2 is more capable and more pleasant to use — it's the go-to choice for Mac developers.

Why use a terminal

Claude Code is a command-line tool, so it has to run in a terminal. Once you're comfortable with the terminal, installing and using Claude Code only takes a few minutes.

Install iTerm2

Download the latest version from the iTerm2 website and drag it into your Applications folder.

Open iTerm2 and you'll see a black (or white) window with a blinking cursor waiting for input — that's the terminal.

The author put together a ready-to-use iTerm2 profile, tuned mainly for these habits:

  • Jump by word with Option: Option+← / Option+→ move the cursor a word at a time — very efficient when editing commands
  • Option as the Meta key: makes bash/zsh shortcuts (like Option+D to delete the next word) work correctly
  • Hotkey Window: a dedicated drop-down terminal window you can summon and dismiss anytime

Download the profile

Run this in the terminal to download the profile to your Desktop:

bash
curl -o ~/Desktop/iTerm2-Profiles.json \
  "https://raw.githubusercontent.com/vectorsss/my-dot-file/refs/heads/main/iterm2/iTerm2-Profiles.json"

Import into iTerm2

Open iTerm2 → menu bar iTerm2 → Settings → Profiles, click Other Actions → Import JSON Profiles… in the bottom-left corner, and pick the iTerm2-Profiles.json you just downloaded to your Desktop.

Set as default (optional)

After importing you'll see two profiles, Default and Hotkey Window. Select Default and click the star in the bottom-left to make it the default — new windows will use this profile automatically.

What the profile configures

FeatureShortcutDescription
Jump forward one wordOption+→Move the cursor to the start of the next word
Jump back one wordOption+←Move the cursor to the start of the previous word
Delete next wordOption+DDelete the word after the cursor
Delete previous wordOption+BackspaceDelete the word before the cursor

Command cheat sheet

Open iTerm2 and try typing these commands (press Enter after each line):

Directory navigation

bash
pwd          # Print the current directory (Print Working Directory)
ls           # List files in the current directory
ls -la       # List all files, including hidden ones and permissions
cd ~/Desktop # Go to the Desktop
cd ..        # Go up one level
cd ~         # Go to your home directory (i.e. /Users/your-username)

File operations

bash
mkdir my-project      # Create a folder
touch hello.txt       # Create an empty file
cp hello.txt copy.txt # Copy a file
mv hello.txt new.txt  # Rename / move a file
rm new.txt            # Delete a file (irreversible!)
rm -rf my-folder      # Delete a folder (irreversible!)

View and edit

bash
cat hello.txt         # Print a file's contents
open .                # Open the current directory in Finder
open hello.txt        # Open a file with its default app

Other essentials

bash
clear                 # Clear the screen (or press Control+L)
history               # Show command history
which node            # Find the actual path of a command
echo $PATH            # Show the PATH environment variable

Keyboard shortcuts

You'll use these every day in the terminal — once they're second nature, you'll work twice as fast:

Cursor movement

ShortcutAction
Control+AJump to the start of the line
Control+EJump to the end of the line
Option+←Jump back one word (after applying the iTerm2 profile)
Option+→Jump forward one word (after applying the iTerm2 profile)

Editing

ShortcutAction
Control+UDelete everything before the cursor
Control+KDelete everything after the cursor
Control+WDelete the previous word
Option+BackspaceDelete the previous word (after applying the iTerm2 profile)

Process control

ShortcutAction
Control+CInterrupt the current program (force stop)
Control+DSend EOF, usually the same as exiting the current shell
Control+ZSuspend the current program and move it to the background

History

ShortcutAction
/ Move back and forth through command history
Control+RSearch command history (matches as you type)

iTerm2 windows

ShortcutAction
Command+TNew tab
Command+WClose the current tab
Command+DSplit vertically
Command+Shift+DSplit horizontally
Command+[ / Command+]Switch between panes

Install Homebrew

Homebrew is the most popular package manager on the Mac, used to install all kinds of developer tools — think of it as an app store for command-line tools.

Run this in iTerm2:

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

During installation you'll be asked for your system password (no characters appear as you type — that's normal, just type it and press Enter) and to install the Xcode Command Line Tools. Confirm each prompt; the whole process takes about 5–15 minutes.

Verify the installation

bash
brew --version
# Output similar to: Homebrew 4.x.x

Apple Silicon (M-series) users

After installing Homebrew, M1/M2/M3/M4 Macs need one extra step to add Homebrew to PATH:

bash
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"

The installer prints this reminder when it finishes — just follow it.

Common brew commands

bash
brew install git          # Install software
brew upgrade git          # Upgrade software
brew uninstall git        # Uninstall software
brew search node          # Search for packages
brew list                 # List installed packages
brew update               # Update Homebrew itself
brew doctor               # Check for environment problems

Install Node.js

Node.js is required to run Claude Code. We recommend nvm (Node Version Manager) to manage Node.js versions so you can switch easily later.

bash
# Install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash

# Load nvm in the current terminal (or restart iTerm2)
source ~/.zshrc

# Install the latest LTS version of Node.js
nvm install --lts

# Verify
node --version   # Should output v20.x.x or higher
npm --version    # npm ships with Node.js

Option 2: Homebrew

If you only need one version, Homebrew is simpler:

bash
brew install node

# Verify
node --version
npm --version

Claude Code requires Node.js 18+

Claude Code requires Node.js 18 or 20 LTS or higher. Run node --version to confirm your version meets the requirement.

Configure an npm mirror (users in mainland China)

If npm is slow, switch to a domestic mirror:

bash
npm config set registry https://registry.npmmirror.com

Verify it took effect:

bash
npm config get registry
# Should output: https://registry.npmmirror.com

Next step: install Claude Code

Your environment is ready — with the terminal, Homebrew and Node.js in place, installing Claude Code is a single command.

FAQ

Q: The terminal says command not found: brew

Homebrew isn't on your PATH. On Apple Silicon Macs run:

bash
eval "$(/opt/homebrew/bin/brew shellenv)"

On Intel Macs run:

bash
eval "$(/usr/local/bin/brew shellenv)"

Then add that line to ~/.zshrc or ~/.zprofile to make it permanent.


Q: nvm: command not found

After installing nvm you need to restart the terminal, or source the config file manually:

bash
source ~/.zshrc
# If that still doesn't work, try:
source ~/.nvm/nvm.sh

Q: npm install is slow or times out

Switch to a domestic mirror:

bash
npm config set registry https://registry.npmmirror.com

Q: The Option-key word jump doesn't work

Make sure you imported the profile and that the Default profile is active. In iTerm2 Settings → Profiles → Keys → General, check that the Left/Right Option key is set to Esc+.