term query
for platform
Query the terminal for information.
Signature
> term query {flags} (query)
Flags
--prefix, -p {one_of(binary, string)}
: Prefix sequence for the expected reply.--terminator, -t {one_of(binary, string)}
: Terminator sequence for the expected reply.--keep, -k
: Include prefix and terminator in the output.
Parameters
query
: The query that will be printed to stdout.
Input/output types:
input | output |
---|---|
nothing | binary |
Examples
Get cursor position.
> term query (ansi cursor_position) --prefix (ansi csi) --terminator 'R'
Get terminal background color.
> term query $'(ansi osc)10;?(ansi st)' --prefix $'(ansi osc)10;' --terminator (ansi st)
Get terminal background color. (some terminals prefer char bel
rather than ansi st
as string terminator)
> term query $'(ansi osc)10;?(char bel)' --prefix $'(ansi osc)10;' --terminator (char bel)
Read clipboard content on terminals supporting OSC-52.
> term query $'(ansi osc)52;c;?(ansi st)' --prefix $'(ansi osc)52;c;' --terminator (ansi st)
Notes
Print the given query, and read the immediate result from stdin.
The standard input will be read right after query
is printed, and consumed until the terminator
sequence is encountered. The terminator
is not included in the output.
If terminator
is not supplied, input will be read until Ctrl-C is pressed.
If prefix
is supplied, input's initial bytes will be validated against it. The prefix
is not included in the output.