it2 session send-key
Send a special key to a session
Synopsis
it2 session send-key [<session-id>] <key> [flags]
Description
Send a key or character to a session.
If no session-id is provided, uses $ITERM_SESSION_ID environment variable.
Supported special keys:
- Basic: enter, tab, escape, backspace, delete, space
- Arrow keys: up, down, left, right
- Navigation: home, end, pageup, pagedown
- Function keys: f1-f12
- Control keys: ctrl-a thru ctrl-z (also C-x, c-x, ^X formats)
- Meta/Alt keys: M-x, alt-x, meta-x (sends ESC+key)
- Shift combos: shift+tab, shift+up/down/left/right, shift+letter
- Complex modifiers: cmd+ctrl+shift+a, etc.
Examples
# Send Enter to current session
$ it2 session send-key enter
# Send Tab to specific session
$ it2 session send-key w0t1p11:SESSION-ID tab
# Send the letter 'q'
$ it2 session send-key q
# Send Escape
$ it2 session send-key escape
# Send Ctrl+C (all formats work)
$ it2 session send-key ctrl-c
$ it2 session send-key C-c
$ it2 session send-key ^C
# Send function keys
$ it2 session send-key f5
$ it2 session send-key f12
# Send Meta/Alt combinations (Emacs-style)
$ it2 session send-key M-x
$ it2 session send-key alt-w
# Send shifted arrow keys
$ it2 session send-key shift+up
$ it2 session send-key shift+tab
# Send complex modifier combinations
$ it2 session send-key cmd+shift+z
$ it2 session send-key ctrl+alt+a
Options
-
--confirm - Prompt for confirmation when using implicit session ID ($ITERM_SESSION_ID)
-
--dry-run - Show what would be affected without executing
-
--no-broadcast - Suppress broadcasting even if enabled
-
--scope - Override IT2_SCOPE env var (none,window,tab,parents,siblings,peers,lineage)
-
--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
- it2 session autorespond - Monitor and automatically respond to session prompts
- it2 session badge - Manage session badges
- it2 session close - Close one or more sessions
- it2 session copy - Copy current selection to clipboard
- it2 session current - Show the current session ID
- it2 session focus - Focus/activate a session
- it2 session focused - Get the currently focused session ID
- it2 session get-buffer - Get buffer contents of a session
- it2 session get-info - Get comprehensive session information
- it2 session get-pid - Get the process ID (PID) of the shell in a session
- it2 session get-screen - Get current screen contents of a session
- it2 session has-shell-integration - Check if shell integration is enabled for a session
- it2 session list - List all iTerm2 sessions
- it2 session lookup - Look up session relationships and hierarchy
- it2 session monitor - Monitor session events in real-time
- it2 session move - Move a session to be a split pane next to another session
- it2 session paste - Paste clipboard content to session
- it2 session process - Process inspection for sessions
- it2 session profile - Manage session profile properties
- it2 session prompt - Get shell prompt metadata for a session
- it2 session resize - Resize a pane in a split layout
- it2 session restart - Restart a session
- it2 session select - Select text in a session
- it2 session send-text - Send text to a session as if typed
- it2 session split - Split a session pane
- it2 session splits - Show split pane layout (moved to 'tab splits')
- it2 session tail - Continuously monitor session output (like tail -f)
- it2 session title - Manage session titles
- it2 session variable - Manage session variables
- it2 session watch - Watch sessions and provide status overview