1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
use fmt;
/// A multiplexer inferred from a nonempty session environment marker.
///
/// This identifies the session manager independently of [`TerminalInfo::kind`]. `TERM=screen*`
/// alone does not establish a Screen session; it may describe emulation used by another
/// multiplexer. If markers conflict, only one kind is selected; see [Detection
/// logic](crate#detection-logic). [`fmt::Display`] returns `tmux`, `screen`, or `zellij`.
///
/// # Example
///
/// ```
/// let info = detect_terminal::detect();
/// if let Some(mux) = &info.multiplexer {
/// println!("Multiplexer: {}", mux.kind);
/// }
/// ```
///
/// [`TerminalInfo::kind`]: crate::TerminalInfo::kind
/// Multiplexer identity with optional command-derived version and client information.
///
/// Returned in [`TerminalInfo::multiplexer`] when a session marker is present. Environment-only
/// detection populates `kind`; every other field is `None`. Enable
/// [`DetectOptions::allow_commands`] through [`detect_with_options`] to request the extra metadata.
/// Missing executables, failed probes, and unavailable values still leave those fields absent.
/// Inspect [`TerminalInfo::command_probes`] to distinguish failed attempts from disabled probing.
///
/// The client fields apply only to tmux. They describe the client selected by tmux, which can be
/// ambiguous when several clients are attached. Screen and Zellij always leave these fields `None`.
/// See [Optional command probes](crate#optional-command-probes) for the blocking execution
/// contract.
///
/// # Example
///
/// Run inside a multiplexer session with its executable on `PATH`. Probes have no timeout.
///
/// ```no_run
/// use detect_terminal::{DetectOptions, detect_with_options};
///
/// let env = std::env::vars_os().collect();
/// let options = DetectOptions {
/// allow_commands: true,
/// ..DetectOptions::default()
/// };
/// let info = detect_with_options(&env, options);
/// if let Some(mux) = &info.multiplexer {
/// println!("Multiplexer: {}", mux.kind);
/// match &mux.version {
/// Some(version) => println!("Version: {version}"),
/// None => println!("Version unavailable; inspect command_probes for details"),
/// }
/// }
/// ```
///
/// [`TerminalInfo::multiplexer`]: crate::TerminalInfo::multiplexer
/// [`TerminalInfo::command_probes`]: crate::TerminalInfo::command_probes
/// [`DetectOptions::allow_commands`]: crate::DetectOptions::allow_commands
/// [`detect_with_options`]: crate::detect_with_options