termcolors

Simple terminal colour chooser and ANSI code generator utility for Linux, written in Python

Overview

termcolors is a small TUI (terminal user interface) utility for working with true-colour (24-bit) ANSI escape sequences in the terminal. It provides a simple way to generate foreground or background ANSI codes from RGB colour values.

Features

Dependencies

pyperclip

Installation

pip install termcolors Or install from source: pip install -e .

Usage

Examples

Interactive mode

    ╭─user at main-frame in ~/some/folder 00-13-48 - 26:93:72
    ╰─∷   termcolors
    termcolors v. 0.9.1 -- interactive mode
    Enter a colour code (R;G;B, decimal), command or help > 9;149;9
    

Terminal output showing a green colour bar generated by termcolours (RGB 9;149;9)

Commands in interactive mode

Batch input

termcolors -f <file>

In the batch input mode any .ssv file with colours specified in the correct format2 is read. All the parsed colours, along with #hex and int triplets and with the corresponding ANSI codes, are printed to stdout after which the program quits.

Named palette

Typing palette in the interactive mode invokes the method. The user is presented with a menu of available palettes, corresponding to .ssv files stored in the assets folder. he palette is then generated and printed to stdout, after which the program quits.

    ╭─user at main-frame in ~/some/folder 00-13-48 - 26:93:72
    ╰─∷   termcolors
    termcolors v. 0.9.1 -- interactive mode
    Enter a colour code (R;G;B, decimal), command or help > palette
    'ansi16' | 'forest_vibes' | 'gruvbox' | 'khaz' | 'material_basic'
    'navy_light_blue' | 'nord' | 'simple' | 'solarized' | 'turquoise_depths'
    Enter a palette name> khaz
    

Terminal output showing a green colour bar generated by termcolours (RGB 9;149;9)

Input format

Input semi-colon separated triplets might be in any of the following forms:

Invalid input values or formats will result in an error.

License

MIT

Footnotes

File with the first line in the form # palette: <name>; filename: <filenamename>.ssv the palette will show in the menu as a <name> option.

See Input format