it2 shell state

Check if shell is ready for input

Synopsis

it2 shell state [<session-id>] [flags]

Description

Check the current state of the shell in a session.

If no session-id is provided, uses $ITERM_SESSION_ID environment variable.

Returns one of four states:
ready - Shell is at prompt, ready for input (exit 0)
busy - Command is currently running (exit 1)
tui - TUI application is active (vim, htop, etc) (exit 2)
unknown - State cannot be determined (exit 3)

State detection uses Shell Integration when available for accurate tracking
of command lifecycle (EDITING/RUNNING/FINISHED states). Falls back to detecting
TUI mode using session.showingAlternateScreen variable.

The exit code can be used in scripts for conditional execution.

Options

-q, --quiet
Quiet mode - no output, only exit code

Options inherited from parent commands

--format (default "text")

Output format (text, json, yaml) - affects how command results are displayed

--timeout

Timeout for API operations - how long to wait for iTerm2 to respond

--url

WebSocket URL for iTerm2 API - typically ws://localhost:1912 for local iTerm2

See Also

  • it2 shell - Shell state detection and prompt tracking

Examples

# Check if shell is ready
$ it2 shell state
ready

# Use in script
$ if it2 shell state --quiet; then
    echo "Shell is ready for commands"
  fi

# Check specific session
$ it2 shell state w0t1p0:ABC123-DEF456

# Get machine-readable JSON output
$ it2 shell state --format json
{"state":"ready","has_shell_integration":true}