Get the xterm closest color to a hexadecimal color.
It works in Node.js, Deno and browsers
// deno
import { hexterm } from "jsr:@jacoborus/hexterm";
// node.js
import { hexterm } from "hexterm";
hexterm("005fd7"); // 26
hexterm("#005fd7"); // 26
hexterm("005ED9"); // 26
hexterm("ff0"); // 11
hexterm("#ff0"); // 11
Install globally
# deno
deno install -n hexterm jsr:@jacoborus/hexterm/cli
# node
npm install -g hexterm
Call from your shell: hexterm <color>
hexterm 005fd7
Remember to wrap the color code between quotes if has numeral prefix (#
)
hexterm '#ff0'
Alternatively, you can call hexterm using npx
npx hexterm 005fd7
deno test
To build npm compatible module:
deno task build-npm
© 2016-2024 Jacobo Tabernero Rey - Released under MIT License