Nodeschool Public Materials

    termcolors

    0.0.6 • Public • Published

    TermColors

    Import and export between multiple terminal colour scheme formats

    Many templates are sourced from the Base16-Builder.

    Colors are handled using tinytinycolor.

    Installation

    npm install --save termcolors
    

    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

    Only some formats support importing.

    Gnome

    • gnome
    • Export

    Guake

    • guake
    • Export

    iTerm2

    • iterm
    • Import
    • Export

    Konsole

    • konsole
    • Export

    MinTTY

    • mintty
    • Export

    Putty

    • putty
    • Export

    Terminator

    • terminator
    • Export

    Termite

    • termite
    • Import
    • Export

    XFCE4 Terminal

    • xfce
    • Export

    Xresources

    • xresources
    • Import
    • Export

    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.toHexString()}}; }'
    
    var cssTemplate = termcolors.export(template);

    Example With Converter:

    var template = 'body { background: {{=c.background}}; }'
    
    var toHex = function (colors) {
        return {
            background: colors.background.toHexString();
        }
    };
    
    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.toHexString();
    });
    
    var cssTemplate = termcolors.export(template, toHex);

    Install

    npm i termcolors@0.0.6

    Version

    0.0.6

    License

    MIT

    Last publish

    Collaborators

    • stayradiated
    • 318h7