it2 session get-buffer

Get buffer contents of a session

Synopsis

it2 session get-buffer [<session-id>] [flags]

Description

Get buffer contents of a session including scrollback history.

Use --wait-stable to wait until the session buffer stops changing before retrieving.
This is useful for automation where you need to wait for command output to complete.

Stability options:
--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

--allow-self

Allow reading buffer from the same session (disabled by default for safety)

--color

Include ANSI color codes in output

--escaped

Show escape sequences as visible characters (like cat -v)

--format (default "table")

Output format (table|json|yaml|text)

--include-empty-lines

Include trailing empty/blank lines in output (default: strip them)

--last (default 0)

Number of last lines to retrieve (alias for --lines)

--lines (default 10000)

Number of lines to retrieve

--scrollback

Include scrollback history

--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

# Get current session buffer
$ it2 session get-buffer

# Get specific session buffer
$ it2 session get-buffer SESSION123

# Get last 100 lines only
$ it2 session get-buffer --lines 100
$ it2 session get-buffer --last 100

# Quick tail-like usage (last 20 lines)
$ it2 session get-buffer --last 20

# Include color/formatting information
$ it2 session get-buffer --color

# Wait until buffer stabilizes before getting (default 2s)
$ it2 session get-buffer --wait-stable

# Wait with quick detection
$ it2 session get-buffer --wait-stable --wait-stable-tolerance=low

# Save session output to file
$ it2 session get-buffer > session-output.txt

# Get JSON format with metadata
$ it2 session get-buffer --format json

# Search through buffer contents
$ it2 session get-buffer | grep "ERROR"

# Archive session output daily
$ it2 session get-buffer SESSION123 > "logs/$(date +%Y%m%d)-session.log"

# Wait for command to complete, then capture output
$ it2 session send-text SESSION123 "long-running-command"
$ it2 session get-buffer SESSION123 --wait-stable --lines 50