JSPM

tmux-colors

0.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 11
  • Score
    100M100P100Q31636F
  • License BSD

Write tmux-compatible color strings and have them work both in the terminal and in tmux.

Package Exports

  • tmux-colors

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (tmux-colors) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

tmux-colors

Write tmux-compatible color strings and have them work both in the terminal and in tmux.

Useful for writing widgets that use colors and need to work in both the terminal and in tmux.

Usage example

tmux-colors accepts strings written in a tmux-compatible format and converts them into terminal compatible output:

var colors = require('tmux-colors');

console.log(colors('#[fg=yellow,bold]Yellow bold#[default] Gray'));

By default, if process.stdout.isTTY is true, then colors will be converted into ANSI color codes. Otherwise, they are directly echoed.

All the following are supported: black, red, green, yellow, blue, magenta, cyan, white, default, bright, bold, dim, underscore, blink, reverse, hidden,italics, color0 ... color255, colour0 ... colour255 and RGB strings (#ff0000).

Options

colors(str, opts)
  • You can pass { tty: true } as the second parameter to force ANSI color codes.
  • You can pass { color: false} to strip out the color strings completely.

colors.styles exposes the styles as ANSI escape codes, which may be useful in some cases.

Specifying colors in tmux

tmux uses a custom format for specifying colors, which is different from the set of codes used in the terminal. For compatibility, tmux-colors also uses the same format: #[attributes]

where attributes are a comma-separated list of 'fg=color' and 'bg=color', for example:

#[fg=yellow,bold]Yellow bold#[default] Gray

Attributes may a comma-delimited list of one or more of: bright (or bold), dim, underscore, blink, reverse, hidden, or italics.

Color may be one of: black, red, green, yellow, blue, magenta, cyan, white, default, colour0 to colour255. Newer tmux versions also support RGB strings such as #ffffff. See man tmux for more info.

tmux-colors also converts these strings to the appropriate TTY color codes for the terminal.