Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marvinhagemeister/kolorist
A tiny utility to colorize stdin/stdout
https://github.com/marvinhagemeister/kolorist
ansi ansi-colors cli colors minimal node tiny
Last synced: 7 days ago
JSON representation
A tiny utility to colorize stdin/stdout
- Host: GitHub
- URL: https://github.com/marvinhagemeister/kolorist
- Owner: marvinhagemeister
- License: mit
- Created: 2020-02-19T20:06:12.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2023-04-22T22:01:43.000Z (almost 2 years ago)
- Last Synced: 2025-01-10T21:04:39.614Z (14 days ago)
- Topics: ansi, ansi-colors, cli, colors, minimal, node, tiny
- Language: TypeScript
- Size: 596 KB
- Stars: 303
- Watchers: 4
- Forks: 7
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-nodejs - kolorist - A tiny utility to colorize stdin/stdout. ![](https://img.shields.io/github/stars/marvinhagemeister/kolorist.svg?style=social&label=Star) (Repository / Command-line Utilities)
README
# kolorist
Tiny library to put colors into stdin/stdout :tada:
![Screenshot of terminal colors](.github/demo.png)
## Usage
```bash
npm install --save-dev kolorist
``````js
import { red, cyan } from 'kolorist';console.log(red(`Error: something failed in ${cyan('my-file.js')}.`));
```You can also disable or enable colors globally via the following environment variables:
- disable:
- `NODE_DISABLE_COLORS`
- `NO_COLOR`
- `TERM=dumb`
- `FORCE_COLOR=0`- enable:
- `FORCE_COLOR=1`
- `FORCE_COLOR=2`
- `FORCE_COLOR=3`On top of that you can disable colors right from node:
```js
import { options, red } from 'kolorist';options.enabled = false;
console.log(red('foo'));
// Logs a string without colors
```You can also strip colors from a string:
```js
import { red, stripColors } from 'kolorist';console.log(stripColors(red('foo')));
// Logs 'foo'
```### License
`MIT`, see [the license file](./LICENSE).