it2 session tail

Display session output (like tail, use -f to follow)

Synopsis

it2 session tail [<session-id>] [flags]

Description

Display the last lines from a session buffer. By default, shows the last N lines
and exits (like 'tail'). Use -f or --follow flag to monitor in real-time (like 'tail -f').

When following, the command polls the session buffer at regular intervals and displays
new content as it appears. Useful for monitoring long-running commands or watching
session output.

Use --wait-stable to wait until the session stabilizes (no buffer changes for 2s by default)
before exiting. This is useful for detecting when builds complete, long-running commands finish,
or terminals become idle. Combine with --wait-stable-tolerance and --wait-stable-max-wait for
advanced control.

Stability options (when using --wait-stable):
--wait-stable - Normal tolerance (2s), max-wait 10s
--wait-stable --wait-stable-tolerance=low - Quick detection (500ms), max-wait 10s
--wait-stable --wait-stable-tolerance=high - Lenient (5s), max-wait 10s
--wait-stable --wait-stable-max-wait=30s - Normal tolerance (2s), but max 30s total

Options

--color

Preserve ANSI color codes
-f, --follow
Follow output continuously (default: show last N lines and exit)

--format (default "table")

Output format (table|json|yaml|text)

--grep

Only show lines matching this pattern

--grep-v

Only show lines NOT matching this pattern
-i, --ignore-case
Case-insensitive pattern matching

--interval (default "1s")

Polling interval for new content
-n, --lines (default 10)
Number of initial lines to show (0 for none)

--on-finish

Only show prompt info when command finishes (requires --show-prompts)

--output-only

Hide command echoes and prompts, show only output

--show-prompts

Show prompt metadata (command, exit status, working directory)

--timeout (default "5s")

Command timeout

--url (default "ws://localhost:1912")

iTerm2 WebSocket URL

--wait-stable

Wait until buffer is stable (uses --wait-stable-tolerance for timing)

--wait-stable-max-wait (default "10s")

Maximum total time to wait for stability (default: 10s). 0 for no limit

--wait-stable-tolerance (default "normal")

Stability tolerance level: low (500ms), normal (2s), high (5s)

See Also

Examples

# Show last 10 lines and exit
$ it2 session tail

# Show last 10 lines from specific session and exit
$ it2 session tail abc123

# Follow output continuously (like tail -f)
$ it2 session tail -f

# Follow specific session continuously
$ it2 session tail -f abc123

# Show more lines initially (using long form)
$ it2 session tail --lines 20

# Show more lines initially (using short form)
$ it2 session tail -n 20

# Filter for errors
$ it2 session tail --grep error

# Exclude debug messages
$ it2 session tail --grep-v DEBUG

# Case-insensitive pattern matching
$ it2 session tail --grep error --ignore-case

# Show only command output (hide prompts)
$ it2 session tail --output-only

# Wait until session stabilizes before exiting (default 2s tolerance)
$ it2 session tail --wait-stable

# Wait with quick detection (500ms low tolerance)
$ it2 session tail --wait-stable --wait-stable-tolerance=low

# Wait with lenient detection (5s high tolerance)
$ it2 session tail --wait-stable --wait-stable-tolerance=high

# Max 30s total wait, exit when stable for 2s
$ it2 session tail --wait-stable --wait-stable-max-wait=30s

# Follow and filter output
$ it2 session tail -f --interval 500ms --grep "✓\|✗"

# Wait for build to complete
$ it2 session tail build-session --wait-stable