Giter Site home page Giter Site logo

masaeedu / termcolors Goto Github PK

View Code? Open in Web Editor NEW

This project forked from stayradiated/termcolors

0.0 2.0 0.0 172 KB

Import and export between multiple terminal colour scheme formats

Home Page: https://www.npmjs.com/package/termcolors

JavaScript 88.26% Shell 11.74%

termcolors's Introduction

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.

Name ID Import Export
Alacritty alacritty
Chrome Secure Shell chromeshell
Gnome gnome
Guake guake
iTerm iterm
JSON json
Konsole konsole
Linux Console linux
MinTTY mintty
Putty putty
Simple Terminal st
Terminal.app terminalapp
Terminator terminator
Termite termite
Plain Text text
Sublime Text / Textmate textmate
XFCE4 Terminal xfce
Xresources xresources

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);

termcolors's People

Contributors

stayradiated avatar slashdeva avatar tuedel avatar daniloisr avatar fedemp avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.