MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / themeColorToAnsi

Function themeColorToAnsi

source code/utils/theme.ts:628–641  ·  view source on GitHub ↗
(themeColor: string)

Source from the content-addressed store, hash-verified

626 * Uses chalk to generate the escape codes, with 256-color mode for Apple Terminal.
627 */
628export function themeColorToAnsi(themeColor: string): string {
629 const rgbMatch = themeColor.match(/rgb\(\s?(\d+),\s?(\d+),\s?(\d+)\s?\)/)
630 if (rgbMatch) {
631 const r = parseInt(rgbMatch[1]!, 10)
632 const g = parseInt(rgbMatch[2]!, 10)
633 const b = parseInt(rgbMatch[3]!, 10)
634 // Use chalk.rgb which auto-converts to 256 colors when level is 2
635 // Extract just the opening escape sequence by using a marker
636 const colored = chalkForChart.rgb(r, g, b)('X')
637 return colored.slice(0, colored.indexOf('X'))
638 }
639 // Fallback to magenta if parsing fails
640 return '\x1b[35m'
641}

Callers 1

generateTokenChartFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected