mirror of
https://github.com/nushell/nushell
synced 2024-12-27 05:23:11 +00:00
32196cfe78
## Related - #10150 - https://github.com/nushell/nushell/pull/10150#issuecomment-1721238336 - #10387 - https://github.com/nushell/nushell/pull/10387#issuecomment-1722228185 # Description `term query`: a command for querying information from the terminal. Prints the `$query`, and immediately starts reading raw bytes from stdin. The standard input will be read until the `terminator` sequence is encountered. The `terminator` is not removed from the output. It also stops on <kbd>Ctrl-C</kbd> with an error. ``` Usage: > term query {flags} <query> Flags: -h, --help: Display the help message for this command -t, --terminator (required parameter) <one_of(binary, string)>: stdin will be read until this sequence is encountered Parameters: query <one_of(binary, string)>: The query that will be printed to stdout ``` This was previously possible with `input` until #10150. `input` command's features such as cursor control, deleting input etc. are useful, but interfere with this use case. `term query` makes the following uses possible: ```nushell # get the terminal size with ansi escape codes def terminal-size [] { let response = term query (ansi size) --terminator 'R' # $response should look like this # Length: 9 (0x9) bytes | printable whitespace ascii_other non_ascii # 00000000: 1b 5b 33 38 3b 31 35 30 52 •[38;150R let sz = $response | bytes at 2..<-1 | decode # 38;150 # $sz should look like 38;150 let size = ($sz | split row ';' | each {into int}) # output in record syntax { rows: $size.0 columns: $size.1 } } ``` ```nushell # read clipboard content using OSC 52 term query $"(ansi --osc '52;c;?')(ansi st)" --terminator (ansi st) | bytes at 7..<-2 | decode | decode base64 | decode ``` # User-Facing Changes - added `ansi query` # Tests + Formatting - Integration tests should be added if possible. |
||
---|---|---|
.. | ||
src | ||
tests | ||
Cargo.toml | ||
LICENSE | ||
README.md |
This crate contains the majority of our commands
We allow ourselves to move some of the commands in nu-command
to nu-cmd-*
crates as needed.
Internal Nushell crate
This crate implements components of Nushell and is not designed to support plugin authors or other users directly.