it2 CLI Examples

Practical command examples for common it2 CLI tasks.

Basic Session Operations

# List all active sessions
it2 session list

# List session IDs only (quiet mode for scripting)
it2 session list -q

# Get current session ID
it2 session current

# Send text to current session
it2 session send-text "echo 'Hello from it2'"

# Split current pane vertically
it2 session split --vertical

# Split current pane horizontally
it2 session split --horizontal

Tab and Window Management

# List all open tabs
it2 tab list

# Create a new tab with profile and badge
it2 tab create "Default" --badge "Server"

# List all open windows
it2 window list

# Create a new window
it2 window create "Default"

Text and Buffer Inspection

# Capture visible screen content
it2 get-screen

# Read scrollback buffer (last 100 lines)
it2 get-buffer --lines 100

# Search scrollback buffer for a pattern
it2 text search "error"

Profile Management

# List available iTerm2 profiles
it2 profile list

# Inspect profile details
it2 profile get "Default"

# Set a profile property
it2 profile property set "Default" "background_color" '{"red": 0.1, "green": 0.1, "blue": 0.1}'

Shell Integration & State

# List shell prompts (requires shell integration)
it2 prompt list

# Check shell state (ready, busy, etc.)
it2 shell state

Illustrative Workflow Script

#!/usr/bin/env bash
# Illustrative Fragment: Multi-Pane Development Setup

# Create tab and capture ID
TAB_ID=$(it2 tab create "Dev" --badge "Dev" --format json | jq -r '.id')

# Split pane and start editor
SIDE_PANE=$(it2 session split --vertical --quiet)
it2 session send-text "$SIDE_PANE" "code ."