A
TERMINAL_SETUP
AI_CLI_TOOLS_v1.0
SYSTEM: TERMINAL_INIT

TERMINAL SETUP GUIDE

Configure your terminal for Claude Code, Gemini CLI, and Codex. Includes status line configuration and platform-specific setup.

status_line_demo.sh
user/my-project | main | S: 0 | U: 2 | A: 1 | 23.4%

// PREREQUISITES

Node.js 20 LTS

All three AI CLI tools require Node.js version 18 or higher. We recommend installing Node.js 20 LTS for maximum compatibility.

Claude Code: 18+ Gemini CLI: 20+ Codex: 18+

Git

Git is required for version control features. All three tools integrate with Git for tracking changes, creating commits, and managing branches.

API keys

Each tool requires an API key from its respective provider. You'll set these up during installation.

// MAC_SETUP

macOS comes with Terminal.app, but there are better alternatives for AI coding:

Warp (recommended for beginners)
FREE

Modern terminal with built-in AI assistance. Great for learning commands.

warp.dev
iTerm2 (power users)
FREE

Highly customizable, split panes, search, and extensive features.

iterm2.com
Terminal.app (built-in)
DEFAULT

Works fine for basic use. No installation needed.

Homebrew is the easiest way to install developer tools on Mac. Open Terminal and run:

Install Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Apple Silicon Macs (M1/M2/M3/M4)

After installation, you MUST add Homebrew to your PATH:

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

Verify installation: brew --version

nvm (Node Version Manager) lets you install and switch between Node.js versions easily.

Step 1: Install nvm

Terminal
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash

Step 2: Add to your shell profile

Add these lines to your ~/.zshrc file:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

Step 3: Restart terminal and install Node

# Restart your terminal, then:
nvm install 20      # Install Node.js 20 LTS
nvm use 20          # Use Node.js 20
node --version      # Verify installation

macOS may already have Git installed. Check first:

git --version

If not installed, use Homebrew:

brew install git

First time? Configure your identity:

git config --global user.name "Your Name"
git config --global user.email "your@email.com"

// WINDOWS_SETUP

WSL2 + Windows Terminal (recommended)
BEST

WSL2 gives you a full Linux environment inside Windows. Most programming tutorials assume Unix-like systems, so this makes following them much easier.

PowerShell
NATIVE

Modern Windows shell. Works for all three CLI tools but some commands differ from tutorials.

Command Prompt (cmd)
LEGACY

Old Windows shell. Not recommended for development work.

Get Windows Terminal: Free from the Microsoft Store. It lets you use PowerShell, CMD, and WSL2 in one app with tabs.

Step 1: Open PowerShell as Administrator

Right-click the Start menu and select "Windows Terminal (Admin)" or "PowerShell (Admin)"

Step 2: Install WSL

PowerShell (Admin)
wsl --install

This installs Ubuntu by default. You'll be prompted to restart.

Step 3: Set up your Linux user

After restart, Ubuntu will open and ask you to create a username and password. This is separate from your Windows login.

After WSL2 is set up: Use Windows Terminal to open an "Ubuntu" tab. All following Node.js and Git commands will work just like on Mac/Linux.

Enable Script Execution

Windows blocks scripts by default. Open PowerShell as Administrator and run:

Set-ExecutionPolicy RemoteSigned

Install Node.js with nvm-windows

  1. 1. Uninstall any existing Node.js installations first
  2. 2. Download nvm-windows from GitHub
  3. 3. Run the installer
  4. 4. Open PowerShell as Administrator and run:
nvm install lts
nvm use lts
node --version

Install Git for Windows

Download and install from git-scm.com. This also includes Git Bash as an alternative shell.

C
// CLAUDE_CODE

Anthropic

Claude Code is Anthropic's CLI tool powered by Claude 4.5 Opus. It can read your codebase, make changes, run commands, and help you ship code faster.

Installation

Terminal
# Install Claude Code
curl -fsSL https://claude.ai/install.sh | bash

# Or with npm (if you prefer)
npm install -g @anthropic-ai/claude-code
PowerShell or WSL2
# Install with npm
npm install -g @anthropic-ai/claude-code

# In WSL2, you can also use:
curl -fsSL https://claude.ai/install.sh | bash

Authentication

Claude Code uses browser-based authentication. Just run:

claude

It will open your browser to sign in with your Anthropic account.

Basic usage

# Start Claude Code in your project
cd your-project
claude

# Or start with a specific task
claude "fix the bug in auth.js"

G
// GEMINI_CLI

Google

Gemini CLI is Google's command-line tool powered by Gemini 3.0 Pro. Excellent for front-end design, working with large documents, and multimodal tasks.

Installation

Terminal / PowerShell
npm install -g @google/gemini-cli

Authentication

Get your API key from Google AI Studio, then:

# Add to your ~/.zshrc or ~/.bashrc
export GEMINI_API_KEY="your-api-key-here"

# Then reload your shell
source ~/.zshrc
# In PowerShell (permanent)
setx GEMINI_API_KEY "your-api-key-here"

# Restart your terminal for changes to take effect

Basic usage

# Start Gemini CLI
gemini

# Chat mode
gemini chat

# One-off query
gemini "explain this code" < myfile.js

O
// CODEX_CLI

OpenAI

Codex is OpenAI's CLI tool powered by GPT 5.1. A capable coding assistant with strong reasoning abilities.

Installation

Terminal / PowerShell
npm install -g @openai/codex

Authentication

Get your API key from OpenAI Platform, then:

# Add to your ~/.zshrc or ~/.bashrc
export OPENAI_API_KEY="your-api-key-here"

# Then reload your shell
source ~/.zshrc
# In PowerShell (permanent)
setx OPENAI_API_KEY "your-api-key-here"

# Restart your terminal for changes to take effect

Basic usage

# Start Codex in your project
cd your-project
codex

# With a specific task
codex "refactor this function to be more efficient"

// STATUS_LINE_CONFIG

What is a status line?

A status line shows real-time information about your coding session right in the terminal. For AI CLI tools, the most valuable info is the context window percentage - how much of the AI's memory you've used.

user/my-project | main | S: 0 | U: 2 | A: 1 | 17.3%

Repo path | Branch | Staged | Unstaged | Added | Context %

Why context percentage matters

The more context you use, the worse the AI performs. Keeping an eye on this helps you know when to start a fresh session. Most users aim to stay under 60% for best results.

Claude Code supports custom status lines through its settings. Here's how to set up the perfect status line with git info and context percentage.

1 Install ccstatusline

Terminal
npm install -g ccstatusline

2 Configure ccstatusline

Create ~/.config/ccstatusline/settings.json:

~/.config/ccstatusline/settings.json
{
  "version": 3,
  "lines": [
    [
      {
        "id": "1",
        "type": "context-percentage",
        "color": "yellow",
        "bold": true,
        "rawValue": true
      }
    ],
    [],
    []
  ],
  "flexMode": "full-minus-40",
  "compactThreshold": 60,
  "colorLevel": 2
}

3 Create the Git status script

Create ~/.claude/statusline-command.sh:

~/.claude/statusline-command.sh
#!/bin/bash

# Read JSON input
input=$(cat)

# Extract current directory from JSON
cwd=$(echo "$input" | sed -n 's/.*"current_dir":"\([^"]*\)".*/\1/p')

# Git information
if git -C "$cwd" rev-parse --git-dir > /dev/null 2>&1; then
  # Get repo name relative to ~/repos/ (change this path!)
  repo_name=$(echo "$cwd" | sed "s|^$HOME/repos/||")

  # Get branch
  branch=$(git -C "$cwd" --no-optional-locks rev-parse --abbrev-ref HEAD 2>/dev/null)

  # Count staged files
  staged=$(git -C "$cwd" --no-optional-locks diff --cached --name-only 2>/dev/null | wc -l)

  # Count unstaged files
  unstaged=$(git -C "$cwd" --no-optional-locks diff --name-only 2>/dev/null | wc -l)

  # Count untracked files
  untracked=$(git -C "$cwd" --no-optional-locks ls-files --others --exclude-standard 2>/dev/null | wc -l)

  printf '\033[01;36m%s\033[00m | \033[01;32m%s\033[00m | S: \033[01;33m%s\033[00m | U: \033[01;33m%s\033[00m | A: \033[01;33m%s\033[00m' \
    "$repo_name" "$branch" "$staged" "$unstaged" "$untracked"
else
  printf '\033[01;36m%s\033[00m' "$cwd"
fi

Change ~/repos/ on line 11 to match your projects directory.

4 Create the wrapper script

Create ~/.claude/statusline-wrapper.sh:

~/.claude/statusline-wrapper.sh
#!/bin/bash

# Read JSON input once
input=$(cat)

# Get git info from existing script
git_info=$(echo "$input" | bash ~/.claude/statusline-command.sh)

# Get context percentage from ccstatusline
context_pct=$(echo "$input" | npx ccstatusline)

# Combine outputs
printf '%s | %s' "$git_info" "$context_pct"

5 Make scripts executable

chmod +x ~/.claude/statusline-command.sh
chmod +x ~/.claude/statusline-wrapper.sh

6 Update Claude settings

Add this to ~/.claude/settings.json:

~/.claude/settings.json
{
  "statusLine": {
    "type": "command",
    "command": "bash ~/.claude/statusline-wrapper.sh"
  }
}

7 Restart Claude Code

Close and reopen Claude Code to see your new status line in action!

G

Gemini CLI status

Gemini CLI shows context usage in its interface. Custom status line configuration is not currently supported in the same way as Claude Code, but you can use shell prompt customization (PS1) to show git information.

Look for the context indicator in the Gemini CLI interface during your session.

O

Codex CLI status

Codex displays token usage information in its interface. For shell-level git status, consider customizing your PS1 prompt or using a tool like oh-my-zsh with a git theme.

Token usage is displayed during conversations in Codex.

// TROUBLESHOOTING

"command not found" error

This usually means the tool isn't in your PATH. Try:

  • 1. Restart your terminal
  • 2. Check if npm's global bin is in PATH: npm bin -g
  • 3. Re-run the installation command

"permission denied" error

Don't use sudo npm install -g! Instead:

  • 1. Use nvm (which doesn't require sudo)
  • 2. Fix npm permissions: npm docs

"invalid API key" or authentication errors

Check that your API key is correctly set:

# Mac/Linux - check if variable is set
echo $OPENAI_API_KEY
echo $GEMINI_API_KEY

# Windows PowerShell
echo $env:OPENAI_API_KEY

Node version errors

If you see errors about Node.js version, upgrade:

nvm install 20
nvm use 20
node --version  # Should show v20.x.x

TERMINAL_READY

Your development environment is configured. Time to start building!