detect-terminal
A Rust library for identifying terminal applications and multiplexers from environment hints. It
keeps application names (TERM_PROGRAM) separate from emulation names (TERM) and records why a
result was chosen. The library has no runtime dependencies.
Detection is a best effort: inherited variables can be stale, and generic TERM values identify an
emulation family rather than the actual application. Color support is also inferred from these hints
and kept separate from identity; Unknown leaves the default to the application. The library does
not query escape sequences, measure capabilities, or apply output policy such as NO_COLOR.
Requirements
Rust 1.88 or newer.
Library
Add the library with cargo add detect-terminal. For local development, use a path dependency on
crates/detect-terminal.
let info = detect;
println!;
if let Some = info.multiplexer
detect() reads the current process environment without running commands. Use detect_from_env()
when you already have an environment snapshot or need controlled inputs for a test.
detect_with_options() can opt into blocking tmux, screen, and zellij commands; those commands have
no timeout. Unknown values remain available in the result.
See the crate documentation for detection precedence, command
behavior, privacy considerations, and supported markers. Build it locally with just docs.
CLI
From this checkout:
The installed binary is detect-terminal; install it from the checkout with
cargo install --path crates/detect-terminal-cli --locked.
The CLI prints human-readable output by default. Run with --help for command and diagnostic
options. Environment and probe details can contain session identifiers or paths; review output
before sharing it. See the
CLI guide
for installation, output formats, and exit statuses.
Development
See CONTRIBUTING.md for setup and checks. The project uses nightly rustfmt for formatting and rumdl for Markdown. Normal builds and tests use stable Rust.
License
Licensed under either MIT or Apache-2.0, at your option.