Created
October 29, 2014 01:25
-
-
Save catdad/3cf37a65c2d5660d858e to your computer and use it in GitHub Desktop.
Very simplified NodeJS colors in the console
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
var color = { | |
red: [31, 39], | |
green: [32, 39], | |
yellow: [33, 39], | |
blue: [34, 39], | |
magenta: [35, 39], | |
cyan: [36, 39], | |
white: [37, 39], | |
gray: [90, 39], | |
dim: [2, 22] | |
}; | |
for (var key in color) { | |
(function(){ | |
var col = '\u001b[' + color[key][0] + 'm', | |
reset = '\u001b[' + color[key][1] + 'm'; | |
color[key] = function(str){ | |
return col + str + reset; | |
}; | |
})(); | |
} | |
console.log(color.red('things and stuff')); | |
console.log(color.yellow('things and stuff')); | |
console.log(color.green('things and stuff')); | |
console.log(color.blue('things and stuff')); | |
console.log(color.cyan('things and stuff')); | |
console.log(color.magenta('things and stuff')); | |
console.log(color.white('things and stuff')); | |
console.log(color.gray('things and stuff')); | |
console.log(color.dim('things and stuff')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment