it2 session restart
Restart a session
Synopsis
it2 session restart <session-id> [flags]
Description
Restart a session, optionally only if it has already exited
Options
-
--dry-run - Show what would be affected without executing
-
--only-if-exited - Only restart the session if it has already exited
-
--scope - Filter sessions by scope (default: all sessions). Options: none, window, tab, parents, siblings, peers, lineage. Overrides IT2_SCOPE env var.
-
--stop-on-error - Stop on first error instead of continuing
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 session - Manage iTerm2 sessions
Examples
# Restart a crashed or exited session
$ it2 session restart abc123
# Only restart if session has already exited
$ it2 session restart --only-if-exited abc123
# Restart current session
$ it2 session restart $ITERM_SESSION_ID
# Restart all exited sessions in window
$ for sid in $(it2 session list --format id); do
it2 session restart --only-if-exited $sid 2>/dev/null
done
# Restart session with custom timeout
$ it2 session restart --timeout 10s abc123