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.
Import the recommended profile
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+Dto 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:
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
| Feature | Shortcut | Description |
|---|---|---|
| Jump forward one word | Option+→ | Move the cursor to the start of the next word |
| Jump back one word | Option+← | Move the cursor to the start of the previous word |
| Delete next word | Option+D | Delete the word after the cursor |
| Delete previous word | Option+Backspace | Delete the word before the cursor |
Command cheat sheet
Open iTerm2 and try typing these commands (press Enter after each line):
Directory navigation
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
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
cat hello.txt # Print a file's contents
open . # Open the current directory in Finder
open hello.txt # Open a file with its default appOther essentials
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 variableKeyboard shortcuts
You'll use these every day in the terminal — once they're second nature, you'll work twice as fast:
Cursor movement
| Shortcut | Action |
|---|---|
Control+A | Jump to the start of the line |
Control+E | Jump 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
| Shortcut | Action |
|---|---|
Control+U | Delete everything before the cursor |
Control+K | Delete everything after the cursor |
Control+W | Delete the previous word |
Option+Backspace | Delete the previous word (after applying the iTerm2 profile) |
Process control
| Shortcut | Action |
|---|---|
Control+C | Interrupt the current program (force stop) |
Control+D | Send EOF, usually the same as exiting the current shell |
Control+Z | Suspend the current program and move it to the background |
History
| Shortcut | Action |
|---|---|
↑ / ↓ | Move back and forth through command history |
Control+R | Search command history (matches as you type) |
iTerm2 windows
| Shortcut | Action |
|---|---|
Command+T | New tab |
Command+W | Close the current tab |
Command+D | Split vertically |
Command+Shift+D | Split 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:
/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
brew --version
# Output similar to: Homebrew 4.x.xApple Silicon (M-series) users
After installing Homebrew, M1/M2/M3/M4 Macs need one extra step to add Homebrew to PATH:
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
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 problemsInstall 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.
Option 1: nvm (recommended)
# 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.jsOption 2: Homebrew
If you only need one version, Homebrew is simpler:
brew install node
# Verify
node --version
npm --versionClaude 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:
npm config set registry https://registry.npmmirror.comVerify it took effect:
npm config get registry
# Should output: https://registry.npmmirror.comNext 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:
eval "$(/opt/homebrew/bin/brew shellenv)"On Intel Macs run:
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:
source ~/.zshrc
# If that still doesn't work, try:
source ~/.nvm/nvm.shQ: npm install is slow or times out
Switch to a domestic mirror:
npm config set registry https://registry.npmmirror.comQ: 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+.