Created
September 12, 2012 23:58
-
-
Save fowlmouth/3710861 to your computer and use it in GitHub Desktop.
ansi colors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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