npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

trucolor-cli

v1.0.2

Published

TTY color toolkit supporting Truecolor (24bit RGB)

Downloads

1

Readme

TruColor

trucolor-cli

A CLI Wrapper for trucolor

Publishing Status

npm Libraries.io
Travis Rollup

Development Status

Travis Libraries.io
Snyk Code-Climate Code-Climate Coverage

Documentation/Help

Twitter

Usage

Installation

npm install --global @thebespokepixel/trucolor-cli

Synopsis:

trucolor [options] "color description"...

Options:
-h, --help     Display this help.
-v, --version  Return the current version on stdout. -vv Return name & version.
-V, --verbose  Be verbose. -VV Be loquacious.
-m, --message  Format message with SGR codes
-i, --in       Output SGR color escape code.
-o, --out      Output cancelling SGR color escape code.
-t, --type     CLI styling flags output.
-r, --rgb      Output color as rgb(r, g, b).
-s, --swatch   Output an isolated color swatch.
--color        Force color depth --color=256|16m. Disable with --no-color

Usage Examples

In it's simplest form, trucolor 'color', will take any of the color expressions listed below and transform it into a simple hexadecimal triplet string, i.e AA00BB, ideal for passing into fish-shell's set_color built-in, or providing the basis of further color processing.

It can return color values and set terminal colors for a wide range of color assignment declarations and manipulation functions. See the examples below.

When outputting SGR codes, colors will be shifted to the availalble 256 or ansi color palette if 24 bit color is unavailable or will be omitted in a monochromatic terminal to make usage across environments safe. The CLI command respects --color=16m, --color=256, --color and --no-color flags. It does not affect value based output, such as the default or --rgb output, it only effects the --in, --out, --message and --swatch outputs.

The motivation for this is to allow more sophisticated graphic visualisation using in modern, xterm-compatible terminal emulators that have added 24 bit support.

Color definition

The color can be defined in any of the following formats:

  • CSS Hexadecimal
    [#]RRGGBB or [#]RGB where R, G and B are 0-F.

  • RGB
    rgb:R,G,B or rgb(R,G,B) where R,G and B are 0-255.
    Spaces can be incuded in rgb(R, G, B) declarations but require quoting/escaping on the CLI.

  • HSL (Hue Saturation Lightness)
    hsl:H,S,L where H is 0-360, S 0-100 and L 0-100

  • HSV (Hue Saturation Value)
    hsv:H,S,V where H is 0-360, S 0-100 and V 0-100

  • HSB (Hue Saturation Brightness) (just an alias for HSV)
    hsb:H,S,B where H is 0-360, S 0-100 and B 0-100

  • HWB (Hue White Black) hwb:H,W,B where H is 0-360, W 0-100 and B 0-100
    See HWB notation @csswg

  • CSS named colors
    Named Colors Examples

  • Special formatters The following keywords modify the meaning or destination of the color, or provide enhanced foramtting. They only work when used with the command switches that actually output SGR codes, namely: --message, --swatch, --in and --out. When used with the default command or with the --rgb switch, they have no effect and the value of the base color (plus any processing) will be output.

    background: Set the background color, rather than the foreground.

    normal: Set the color to the default foreground and background.
    reset: Sets colors and special formatting back to the default.

    bold: Set the font to bold.
    italic: Set the font to italic.
    underline: Set underline.
    dim: Set the colour to 50% opacity.
    invert: Invert the foreground and background.
    blink: Annoying as a note in Comic Sans, attached to a dancing, purple dinosaur with a talking paperclip.

    All of the above formatters need the correct code to end the range, either provided by using the --out switch, using the reset keyword, or simply use the --message option to automatically set the end range SGR code. Using normal alone won't fully clear the formatting.

Formatters Examples

Color manipulation

A number of color operations can be specified, either before or after the base color declaration.

light: lighten by 20% dark: darken by 20% lighten percent: lighten by percent darken percent: darken by percent mono: make monochrome saturate or sat percent: saturate by percent desaturate or des percent: desaturate by percent spin degrees: spin hue by by degrees color mix color: mix colors

Multiple Inputs

trucolor will output a list of color values if more than one base color is specified, allowing color assignment in a single block allowing easy ingest using read. Each color will be output on it's own line, and named according to the input base color. The names can be overridden by providing a name: before the base color.

> trucolor red yellow green purple
red: ff0000
yellow: ffff00
green: 008000
purple: 800080

> trucolor Po: red LaaLaa: yellow Dipsy: green TinkyWinky: purple
Po: ff0000
LaaLaa: ffff00
Dipsy: 008000
TinkyWinky: 800080

> trucolor hsl:120,100,50 apples: orange spin 180
hsl-120-100-50: 00ff00
apples: 005aff