An open API service indexing awesome lists of open source software.

https://github.com/jacoborus/hexterm

Convert hexadecimal color codes to closest Xterm
https://github.com/jacoborus/hexterm

convert hexadecimal-color xterm

Last synced: 6 months ago
JSON representation

Convert hexadecimal color codes to closest Xterm

Awesome Lists containing this project

README

          

# hexterm

Get the xterm closest color to a hexadecimal color.

It works in Node.js, Deno and browsers

[![JSR](https://jsr.io/badges/@jacoborus/hexterm)](https://jsr.io/@jacoborus/hexterm)
[![npm version](https://badge.fury.io/js/hexterm.svg)](https://www.npmjs.com/package/hexterm)

## Usage

### Programatically

```js
// 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
```

### CLI

Install globally

```sh
# deno
deno install -n hexterm jsr:@jacoborus/hexterm/cli

# node
npm install -g hexterm
```

Call from your shell: `hexterm `

```sh
hexterm 005fd7
```

Remember to wrap the color code between quotes if has numeral prefix (`#`)

```sh
hexterm '#ff0'
```

Alternatively, you can call **hexterm** using npx

```sh
npx hexterm 005fd7
```

## Test

```sh
deno test
```

## Development

To build npm compatible module:

```sh
deno task build-npm
```

---

© 2016-2024 [Jacobo Tabernero Rey](https://github.com/jacoborus) - Released under
[MIT License](https://raw.github.com/jacoborus/hexterm/master/LICENSE)