it2 session lookup split-root
Look up the root session of a split tree
Synopsis
it2 session lookup split-root [<session-id>] [flags]
Description
Look up the root session of a split tree by walking up the parent chain.
When sessions are created via splitting, they form a tree hierarchy with parent-child
relationships. This command finds the topmost session (root) of the split tree that
contains the given session.
This is different from 'session parent' which returns the immediate parent. The split-root
command walks up the entire parent chain to find the root session.
If no session ID is provided, uses the current session from ITERM_SESSION_ID.
If the session is already a root (has no parent), returns the session itself.
Options
-
--json - Output result as JSON
-
-q,--quiet - Only output the root session ID (for scripting)
-
-s,--short - Output only the first 8 characters of the session ID
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 lookup - Look up session relationships and hierarchy
Examples
# Basic Usage
it2 session split-root
it2 session split-root sess_abc123
# Short format (first 8 characters)
it2 session split-root -s
# Scripting Example - Find all sessions in the same split tree
ROOT=$(it2 session split-root -q)
it2 session list --format json | jq -r ".[] | select(.parent == \"$ROOT\" or .id == \"$ROOT\") | .id"