Skip to content

Instantly share code, notes, and snippets.

@zoxon
Last active February 3, 2025 03:47
Show Gist options
  • Save zoxon/eea23ba49857fb7b11b831a9d90c1022 to your computer and use it in GitHub Desktop.
Save zoxon/eea23ba49857fb7b11b831a9d90c1022 to your computer and use it in GitHub Desktop.
/**
* @see https://stackoverflow.com/questions/9781218/how-to-change-node-jss-console-font-color
* @see https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
*/
export const COLOURS = {
$: (c: number) => (str: string) => `\x1b[${c}m` + str + '\x1b[0m',
gray: (str: string) => COLOURS.$(90)(str),
cyan: (str: string) => COLOURS.$(36)(str),
yellow: (str: string) => COLOURS.$(33)(str),
green: (str: string) => COLOURS.$(32)(str),
red: (str: string) => COLOURS.$(31)(str),
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment