THIS IS A FORK, ADDS JETBRAINS IDE COMPATIBILITY
This is a fork of the original "colors" module that fixes an issue with color output in JetBrains IDE's. A pull request (https://github.com/Marak/colors.js/pull/150) has been made on the original repo but has not yet been merged. While we wait for merge, this repo will exist to allow a drop-in replacement with JetBrains support.
You can use this forked version of colors as a drop-in replacement via:
npm install irrelon-colors
get color and style in your node.js console
Installation
npm install irrelon-colors
colors and styles!
text colors
- black
- red
- green
- yellow
- blue
- magenta
- cyan
- white
- gray
- grey
background colors
- bgBlack
- bgRed
- bgGreen
- bgYellow
- bgBlue
- bgMagenta
- bgCyan
- bgWhite
styles
- reset
- bold
- dim
- italic
- underline
- inverse
- hidden
- strikethrough
extras
- rainbow
- zebra
- america
- trap
- random
Usage
By popular demand, colors
now ships with two types of usages!
The super nifty way
var colors = ; console; // outputs green textconsole // outputs red underlined textconsole; // inverses the colorconsole; // rainbowconsole; // Drops the bass
or a slightly less nifty way which doesn't extend String.prototype
var colors = ; console; // outputs green textconsole // outputs red underlined textconsole; // inverses the colorconsole; // rainbowconsole; // Drops the bass
I prefer the first way. Some people seem to be afraid of extending String.prototype
and prefer the second way.
If you are writing good code you will never have an issue with the first approach. If you really don't want to touch String.prototype
, the second usage will not touch String
native object.
Disabling Colors
To disable colors you can pass the following arguments in the command line to your application:
node myapp.js --no-color
string substitution
Console.logvar name = 'Marak';console;// outputs -> 'Hello Marak'
Custom themes
Using standard API
var colors = ; colors; // outputs red textconsole; // outputs yellow textconsole;
Using string safe API
var colors = ; // set single propertyvar error = colorsred;; // set themecolors; // outputs red textconsole; // outputs yellow textconsole;
Combining Colors
var colors = ; colors; console;
Protip: There is a secret undocumented style in colors
. If you find the style you can summon him.