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.9.3.tar.gz (116.6 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.9.3-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: termcolours-0.9.3.tar.gz
  • Upload date:
  • Size: 116.6 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.9.3.tar.gz
Algorithm Hash digest
SHA256 f8d3ae29bcf29e0255b2117cb74f4d8790a4f7e875726f554cd27f35b99df07d
MD5 4c4c486d82dc913f57c1fd9e717826ec
BLAKE2b-256 fb70de9f2b4eef577da29bd98fc382b8ec20cee4848dbe1e0811cd3697f8a3c0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: termcolours-0.9.3-py3-none-any.whl
  • Upload date:
  • Size: 16.9 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.9.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3b64a6f5e1a1b9ce46727d228008bb438a43a9bd929b3e8db8a543f47adee52c
MD5 b4e3a1dc1d98dbbf54953a16ad64fd46
BLAKE2b-256 063fe342a216b6bfd2712756c05eb202ddaa2f0cad5ed6a0c4fda206d94bd354

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