MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / is_light_terminal

Function is_light_terminal

crates/openshell-tui/src/theme.rs:220–226  ·  view source on GitHub ↗

Detect whether the terminal has a light background using OSC 11. Uses `terminal-colorsaurus` to send an OSC 11 query to the terminal, which returns the actual background RGB color. This works reliably on iTerm2, Terminal.app, `WezTerm`, Alacritty, and most modern terminals. Falls back to `false` (dark) if the terminal doesn't respond to the query (e.g. `TERM=dumb`, piped output, very old termina

()

Source from the content-addressed store, hash-verified

218/// Falls back to `false` (dark) if the terminal doesn't respond to the
219/// query (e.g. `TERM=dumb`, piped output, very old terminals).
220fn is_light_terminal() -> bool {
221 use terminal_colorsaurus::{QueryOptions, ThemeMode as ColorsaurusMode};
222 matches!(
223 terminal_colorsaurus::theme_mode(QueryOptions::default()),
224 Ok(ColorsaurusMode::Light)
225 )
226}
227
228#[cfg(test)]
229mod tests {

Callers 1

detectFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected