Skip to content

Instantly share code, notes, and snippets.

@fowlmouth
Created September 12, 2012 23:58
Show Gist options
  • Save fowlmouth/3710861 to your computer and use it in GitHub Desktop.
Save fowlmouth/3710861 to your computer and use it in GitHub Desktop.
ansi colors
from strutils import format
type TColor = enum
black = 0, red, green, yellow, blue, magenta, cyan, white, default
proc color(s: string; fg: TColor; bg = black): string =
result = "\x1B[$1;$2m$3\x1B[0m".format(fg.int + 30, bg.int + 40, s)
echo color("error!", red)
echo color("sup", green, yellow)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment