MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / detectTerminalTheme

Function detectTerminalTheme

apps/kimi-code/src/tui/theme/detect.ts:25–38  ·  view source on GitHub ↗
(opts: DetectOptions = {})

Source from the content-addressed store, hash-verified

23}
24
25export async function detectTerminalTheme(opts: DetectOptions = {}): Promise<ResolvedTheme> {
26 if (!isInteractiveTerminal()) return "dark";
27 if (isColorOptOut()) return "dark";
28
29 const fromOsc = await queryOsc11({
30 timeoutMs: opts.timeoutMs ?? TERMINAL_THEME_DETECT_TIMEOUT_MS,
31 });
32 if (fromOsc !== null) return fromOsc;
33
34 const fromColorFgBg = parseColorFgBg(process.env["COLORFGBG"]);
35 if (fromColorFgBg !== null) return fromColorFgBg;
36
37 return "dark";
38}
39
40function isInteractiveTerminal(): boolean {
41 return (process.stdin.isTTY ?? false) && (process.stdout.isTTY ?? false);

Callers 1

getColorPaletteFunction · 0.90

Calls 4

isInteractiveTerminalFunction · 0.85
isColorOptOutFunction · 0.85
queryOsc11Function · 0.85
parseColorFgBgFunction · 0.85

Tested by

no test coverage detected