it2 session lookup before
Look up the pane immediately before (left or above)
Synopsis
it2 session lookup before [<session-id>] [flags]
Description
Look up the session in the pane immediately before the given session.
This performs spatial lookup that adapts to split direction:
- In a horizontal split (left-to-right): finds the pane to the left
- In a vertical split (top-to-bottom): finds the pane above
If no session ID is provided, uses the current session from ITERM_SESSION_ID.
If there is no pane before, returns empty output.
Examples
Basic Usage
$ it2 session lookup before
$ it2 session lookup before sess_abc123
# Scripting Example - Focus previous pane
$ prev=$(it2 session lookup before -q)
$ if [ -n "$prev" ]; then
$ it2 session focus "$prev"
$ fi
Options
-
--json - Output result as JSON
-
-q,--quiet - Only output the session ID (for scripting)
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
- it2 session lookup above - Look up the pane immediately above
- it2 session lookup after - Look up the pane immediately after (right or below)
- it2 session lookup ancestors - Look up all ancestor sessions
- it2 session lookup children - Look up immediate children sessions
- it2 session lookup descendants - Look up all descendant sessions
- it2 session lookup lineage - Look up complete lineage (ancestors and descendants)
- it2 session lookup parent - Look up the parent session ID
- it2 session lookup siblings - Look up sibling sessions
- it2 session lookup split-root - Look up the root session of a split tree
- it2 session lookup tab - Look up which tab contains a session
- it2 session lookup window - Look up which window contains a session