send
Transmit keystrokes to an interactive terminal without waiting for command results; use for Ctrl+C interrupts, answering prompts, tab completion, or driving vim/less/top.
Instructions
Send keystrokes without waiting for a command's result (that is
run). ORDER: all of text is typed first (literally; a newline in it
is Enter), THEN the keys are pressed in list order. To press a key
before typing (escape, then an ex command), make two calls.
For: interrupting (ctrl+c; ctrl+d ends input, or gdb/python at their
prompt; q leaves a pager), answering a one-character prompt, tab
completion, history and arrows in a REPL, and driving full-screen
programs (vim, less, top). Command lines go through run, which waits
for their result; send only waits until output pauses for settle_ms
(at most wait_ms) and returns what appeared -- or, while a full-screen
program runs, the rendered screen with the cursor position: screen=
"full" (every row), "changes" (only rows changed since the screen last
returned: cheapest for editing), or "cursor" (the rows around the
cursor). With nothing to send, it just reads what is new.
Keys are names such as ctrl+c, ctrl+d, enter, tab, escape, backspace,
up, down, left, right, home, end, pageup, pagedown, f1-f12, alt+x, or
any single character. Shell commands that finish during the call are
reported with their exit status. Refuses, like run, to type over a
human's unsubmitted line unless force. When nothing new appears, or
a program is still in the foreground after ctrl+c, the reply names what
is running there.
signal ("TERM", "KILL", "INT", "HUP", "QUIT"), instead of text and
keys, sends that signal to the terminal's foreground job -- never the
session's own shell or program: for a job that ignores ctrl+c and
ctrl+d. TERM first; KILL if it survives. Prefer it to pkill from
outside, which can hit the session's own shell.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| keys | No | key names pressed after the text, in order: ctrl+c, ctrl+d, enter, tab, escape, backspace, up, down, left, right, home, end, pageup, pagedown, f1-f12, alt+x, or a single character | |
| text | No | typed literally, first; a newline in it is Enter | |
| force | No | type even over someone else's unsubmitted line at the prompt, discarding it first (only for a line you know is stale); with `signal`: send it although the foreground job is ssh, which it would end | |
| screen | No | with a full-screen program: "full" (every row), "changes" (rows changed since the last screen you saw; cheapest when editing), or "cursor" (the rows around the cursor) | full |
| signal | No | instead of text and keys: "TERM", "KILL", "INT", "HUP" or "QUIT", sent to the foreground job (never the session's own shell or program) when ctrl+c and ctrl+d fail; TERM first | |
| session | Yes | the session's name (from session_create or session_list) | |
| wait_ms | No | the most to wait for output to settle before replying (milliseconds) | |
| max_lines | No | lines of output, or rows of the screen, shown in the reply | |
| settle_ms | No | reply once output has paused this long (milliseconds) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |