Created
December 22, 2011 19:55
-
-
Save edwardhotchkiss/1511616 to your computer and use it in GitHub Desktop.
NodeJS CLI Terminal Colors
This file contains 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
/*! | |
__defineGetter__(<ANSI supported color>, fn | |
http://en.wikipedia.org/wiki/ANSI_escape_code#CSI_codes | |
*/ | |
['magenta','yellow','green','blue','cyan','red'].forEach(function(color) { | |
var colorized = '\u001b[#m'; | |
String.prototype.__defineGetter__(color, function(){ | |
var options = { | |
cyan : 6, | |
magenta : 5, | |
blue : 4, | |
yellow : 3, | |
green : 2, | |
red : 1, | |
reset : 0 | |
}; | |
return colorized.replace(/#/, '3'+options[color])+this+colorized.replace(/#/, 0); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment