Skip to main content

Interactive terminal color picker

Project description

termcolours

CI Python License

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

Overview

termcolours 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

  • Convert colours, passed as RR;GG;BB strings, to ANSI sequences
  • Support for foreground and background colours
  • Batch input (see Usage)
  • Named palettes generation (see Usage)
  • Input based on semi-colon separated RGB triplets
  • Designed as a terminal application.

Dependencies

  • pyperclip

Installation

pip install termcolours

Or install from source:

pip install -e .

Usage

  • Interactive mode: running termcolours without arguments prompts the user for input (e.g. 9;149;9).

  • Batch input: termcolours -f <file>, where <file> is an .ssv file containing colour codes -- each line should be of the form RR;GG;BB;<fmt>, <fmt> being one of decm, hexa or prct.

  • Named palette generation -- if .ssv files1 are stored in the assets folder, termcolours will automatically generate a palette from them, displaying a menu to choose from.

Examples

Interactive mode

╭─user at main-frame in ~/some/folder 00-13-48 - 26:93:72
╰─∷   termcolours
termcolours 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
  • fg/bg to copy the current colour to the clipboard (ANSI foreground/background, respectively).
  • decm: sets conversion format from a decimal triplet.
  • hexa: sets conversion format from hexadecimal triplet.
  • prct: sets conversion format from percentage triplet.
  • help: prints help message.
  • palette: generates a named palette, from file in the assets folder.
  • quit: exits the application.

Batch input

termcolours -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. The 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
╰─∷   termcolours
termcolours 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:

  • decimal, e.g. 10;90;255 (name: decm)
  • hexadecimal, e.g. a;5a;ff (name: hexa)
  • percentage, e.g. 0.04;0.355;1 (name: prct)

Invalid input values or formats will result in an error.

License

MIT

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

  2. See Input format

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

termcolours-0.11.3.tar.gz (116.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

termcolours-0.11.3-py3-none-any.whl (122.4 kB view details)

Uploaded Python 3

File details

Details for the file termcolours-0.11.3.tar.gz.

File metadata

  • Download URL: termcolours-0.11.3.tar.gz
  • Upload date:
  • Size: 116.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.2 cpython/3.10.19 HTTPX/0.28.1

File hashes

Hashes for termcolours-0.11.3.tar.gz
Algorithm Hash digest
SHA256 04dfb0dffd18ae45e394e41c0771bafdc83f67b5bdbe3da5c5096a66ff13cdae
MD5 d48f3a0ce5859e9b31129ca80530bc3b
BLAKE2b-256 6907fd14da336b97208af8797d968ca4c6eca5f1d46213b7d82cc664f648adeb

See more details on using hashes here.

File details

Details for the file termcolours-0.11.3-py3-none-any.whl.

File metadata

  • Download URL: termcolours-0.11.3-py3-none-any.whl
  • Upload date:
  • Size: 122.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.2 cpython/3.10.19 HTTPX/0.28.1

File hashes

Hashes for termcolours-0.11.3-py3-none-any.whl
Algorithm Hash digest
SHA256 600c3c25dd603c5fed1b6a089c654afb5b49ba383f6f9e3aa660c1e7822d4a32
MD5 139efe8686d1de630fb1ce01692c6732
BLAKE2b-256 df8df410f12567868caa83a4dacd8ee771b6f6ed5374940c19c74d9da3ec37a1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page