Utility to determine terminal color depth and iTerm2 detection.
// Source: https://github.com/google-gemini/gemini-cli | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import process from 'node:process';
/**
* Returns the color depth of the current terminal.
* Returns 24 (TrueColor) if unknown or not a TTY.
*/
export function getColorDepth(): number {
return process.stdout.getColorDepth ? process.stdout.getColorDepth() : 24;
}
/**
* Returns true if the terminal has low color depth (less than 24-bit).
*/
export function isLowColorDepth(): boolean {
return getColorDepth() < 24;
}
let cachedIsITerm2: boolean | undefined;
/**
* Returns true if the
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key