0.7.3 • Published 3 years ago

termcolors v0.7.3

Weekly downloads
16
License
MIT
Repository
github
Last release
3 years ago

TermColors

Import and export between multiple terminal colour scheme formats

Many templates are sourced from the Base16-Builder.

Colors are handled using Colr.

Installation

npm install termcolors

Terminal Usage

Use the -i and -o flags to set the input and output formats. Pipe the input data into stdin.

Missing colors will be automatically replaced with the default colors.

Reading from one file and writing to another:

$ termcolors -i xresources -o json < ~/.Xresources > output.json

Reading from xrdb output, and writing to stdout:

$ xrdb -q | termcolors -i xresources -o text

JS API Usage

var fs = require('fs');
var termcolors = require('termcolors');

var xresources = fs.readFileSync('~/.Xresources', 'utf8');
var colors = termcolors.xresources.import(xresources);

var iterm = termcolors.iterm.export(colors);
fs.writeFile('~/config.itermcolors', iterm);

Supported Formats

Note: only a select few formats support importing.

NameIDImportExport
Alacrittyalacritty
Chrome Secure Shellchromeshell
Gnomegnome
Guakeguake
iTermiterm
JSONjson
Kittykitty
Konsolekonsole
Linux Consolelinux
lxterminallxterminal
MinTTYmintty
Puttyputty
Simple Terminalst
Terminal.appterminalapp
Terminatorterminator
Termitetermite
Plain Texttext
Sublime Text / Textmatetextmate
Tilixtilix
urxvturxvt
Walwal
XFCE4 Terminalxfce
Windows TerminalwindowsTerminal
Xresourcesxresources
XSHELLxshell

DIY Export

Templates use doT.js.

Check the templates folder for some examples.

Usage:

termcolors.export(template, [transformer])

  • template (string)
  • transformer (function)

The transformer is an optional function that is passed the colors input into the template and can transform them for use in the template.

This is useful so that you don't have to use the tinycolor

Example Without Converter:

var template = 'body { background {{=c.background.hexString()}}; }'

var cssTemplate = termcolors.export(template);

Example With Converter:

var template = 'body { background: {{=c.background}}; }'

var toHex = function (colors) {
    return {
        background: colors.background.hexString();
    }
};

var cssTemplate = termcolors.export(template, toHex);

Example With Lodash Mapping:

var _ = require('lodash');
var template = 'body { background: {{=c.background}}; }'

var toHex = _.partialRight(_.mapValues, function (color) {
    return color.hexString();
});

var cssTemplate = termcolors.export(template, toHex);
0.7.3

3 years ago

0.7.2

3 years ago

0.7.1

3 years ago

0.7.0

3 years ago

0.5.0

7 years ago

0.4.2

7 years ago

0.4.1

7 years ago

0.4.0

7 years ago

0.3.0

7 years ago

0.2.17

8 years ago

0.2.16

9 years ago

0.2.15

9 years ago

0.2.14

9 years ago

0.2.13

9 years ago

0.2.12

9 years ago

0.2.11

9 years ago

0.2.10

10 years ago

0.2.9

10 years ago

0.2.8

10 years ago

0.2.7

10 years ago

0.2.6

10 years ago

0.2.5

10 years ago

0.2.4

10 years ago

0.2.3

10 years ago

0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.0

10 years ago

0.0.10

10 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago