#[non_exhaustive]pub struct TerminalInfo {Show 13 fields
pub kind: TerminalKind,
pub version: Option<String>,
pub term_program: Option<String>,
pub term_program_version: Option<String>,
pub term: Option<String>,
pub colorterm: Option<String>,
pub raw_name: Option<String>,
pub multiplexer: Option<MultiplexerInfo>,
pub color: ColorInfo,
pub detected_via: Vec<DetectionSource>,
pub identifiers: Vec<Identifier>,
pub raw_env_subset: BTreeMap<String, String>,
pub command_probes: Vec<CommandProbe>,
}Expand description
Terminal identity, multiplexer metadata, inferred color support, and their evidence.
Obtain this result with detect,
detect_from_env,
or detect_with_options. An unknown terminal is a valid result,
and a known multiplexer does not imply a known terminal application.
§Reading the result
Start with kind, version, and
multiplexer. A kind can identify an emulation family rather than an
application, and version metadata may be absent even for a known kind.
For unexpected or unknown results, inspect detected_via and
identifiers. The raw term_program, term_program_version, term,
and colorterm fields preserve the input hints even when they do not affect the result.
raw_name is a convenience fallback label, not the detected application’s name.
raw_env_subset contains consulted variables when capture is enabled;
command_probes contains attempted commands when probing is enabled.
These diagnostics can contain private values. See Diagnostics and
privacy and Detection logic.
§Example
let info = detect_terminal::detect();
println!("Terminal: {}", info.kind);
if let Some(version) = &info.version {
println!("Version: {version}");
}
for source in &info.detected_via {
println!("Selected using: {source}");
}
// Debug formatting escapes control characters in raw environment values.
println!(
"Program hint: {:?}; emulation hint: {:?}",
info.term_program, info.term
);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.kind: TerminalKindApplication or emulation family selected from the available hints.
See Edge cases and likely mismatches when a
marker may be inherited or a TERM name is shared by multiple applications.
version: Option<String>TERM_PROGRAM_VERSION only when TERM_PROGRAM identified the selected kind.
A fallback match never borrows a version belonging to another application or multiplexer.
term_program: Option<String>Raw TERM_PROGRAM, including unknown or empty values.
term_program_version: Option<String>Raw TERM_PROGRAM_VERSION, including when its owner is unknown.
term: Option<String>Raw TERM describing the emulation environment.
colorterm: Option<String>Raw COLORTERM, including unrecognized or empty values. It can be inherited.
raw_name: Option<String>Raw TERM_PROGRAM if present, otherwise TERM.
This convenience label can name something different from the selected kind.
multiplexer: Option<MultiplexerInfo>One selected multiplexer, independently of the terminal match.
color: ColorInfoColor support inferred from the hints, with evidence separate from terminal identity.
detected_via: Vec<DetectionSource>Evidence for the terminal match, empty when the kind is unknown.
identifiers: Vec<Identifier>Matching environment key/value pairs, empty for unknown or command-derived matches.
raw_env_subset: BTreeMap<String, String>Existing variables consulted during detection, when diagnostic capture is enabled.
Absent keys and unrelated variables are omitted. Disabling capture does not redact the other fields in this result. Values may contain session identifiers and paths.
command_probes: Vec<CommandProbe>All attempted probes, empty when command execution is disabled or no mux marker matches.