hty send
Deliver input to a running session’s PTY, exactly as if a user had typed it. You can send plain text, symbolic key names, raw bytes, or a sequenced combination of all three.
The <session> argument accepts a session name, a full UUID, or a unique UUID prefix. If only one session is running, you can omit it.
Reference
hty send [SESSION] --text "..." | --raw-text "..." | --key NAME | --seq "..." | --bytes-hex HEX
Send input to a session. Exactly one of --text, --raw-text, --key,
--seq, --bytes-hex is required.
Flags:
--text STRING UTF-8 text with C-style escapes (\n \t \r \\ \e).
--raw-text STRING UTF-8 bytes sent verbatim. No escape processing —
`\n` stays as literal backslash-n. Use this when
you want to type source code or other content that
contains backslashes you don't want interpreted.
Prefer over --text when shell quoting gets hairy.
--key NAME Named key with optional modifiers.
Supports ctrl-, alt-/meta-, shift- prefixes,
function keys (f1-f12), and combinations like
ctrl-alt-f or shift-up. Run `hty keys` for details.
--seq STRING Send a sequence of keys, text, and delays in one call.
Quoted strings are text, durations (e.g. 200ms, 1s)
are pauses, and bare words are key names.
Example: --seq '"hello" 200ms enter 500ms "world"'
--bytes-hex HEX Raw bytes encoded as hex.
Delay flags (optional, combine with any mode above):
--delay-before DUR Sleep before sending (e.g. 200ms, 1s).
--delay-after DUR Sleep after sending.
--delay-char DUR Send text character-by-character with a delay
between each. Only works with --text, --raw-text,
or --seq.
Wait + snapshot flags (fuse send + wait + snapshot into one round-trip):
--snapshot Include the post-action snapshot in the response.
Combines with --json and --ansi like `hty snapshot`.
--wait-duration DUR Sleep DUR after sending, then snapshot. Requires
--snapshot (otherwise use --delay-after).
--wait-until-idle [MS]
Block until the screen has been quiet for MS
milliseconds (default 100). The idle window is
measured from the moment this op begins on the
server, so a session that was already quiet
before the send won't trip the check immediately.
--wait-until-text STR Block until STR appears in the rendered buffer.
--wait-until-regex RE Block until RE (POSIX extended) matches.
--wait-until-exit Block until the child process exits.
--timeout DUR Cap on any --wait-until-* (default 30s; 0 = none).
--json With --snapshot, emit `{ok, matched, elapsed_ms,
snapshot, ...}` instead of the plain buffer.
--ansi With --snapshot, print the styled ANSI rendering
instead of the plain buffer.
Examples
# Type into an insert-mode editor
hty send my-session --text "ihello world"
# Confirm a yes/no prompt
hty send my-session --text "y\n"
# Press Escape
hty send my-session --key esc
# Send Ctrl-C
hty send my-session --key ctrl-c
# Type text, then press enter after 200ms
hty send my-session --seq '"hello" 200ms enter'
# Send raw bytes (the up-arrow escape sequence)
hty send my-session --bytes-hex "1b5b41"Every input sent via hty send is recorded in the session log as an input event, making sessions fully reproducible and auditable.
Last updated on