Convert iTerm2 profile colors to RGB dataset
As a user of iTerm2 and a developer that wants to use python packages supporting colorization such as Rich, I want to extract the colors from my iTerm2 Profile into an RGB dataset that provides:
- Background (R,G,B)
- Foreground (R,G,B)
- List of 8 "normal" colors of (R, G, B)
- List of 8 "bright" colors of (R, G, B)
Usage
You will first need to export your profile colors from iTerm, as described in the section below. You can then either use this package directly or programaticaly.
direct module
Consider an iTerm profile with color values that look like this in the app:
After exporting these settings to the default filename "Untitled.itemcolors", run python:
python -m iterm2_colors2rgb Untitled.itermcolors
Outputs (formatted for clarity):
(
(0, 0, 0),
(199, 199, 199),
[(0, 0, 0), (201, 27, 0), (0, 194, 0), (199, 196, 0), (2, 37, 199), (202, 48, 199), (0, 197, 199), (199, 199, 199), (104, 104, 104)],
[(255, 110, 103), (95, 250, 104), (255, 252, 103), (104, 113, 255), (255, 119, 255), (96, 253, 255), (255, 255, 255)]
)
programmatic
from iterm2_colors2rgb import iterm2_colors2rgb
# as a tuple (bg, fb, normal_list, bright_list)
colors = iterm2_colors2rgb("Untitled.itermcolors")
Installation
pip install iterm2-colors2rgb
Exporting Profile Colors from iTerm
Steps:
- Open the iTerm2 app settings
- Select the Prefrences option
- Select the Profiles option
- Select the profile that you want to export
- Click the Color Presents ... dropdown to reveal the Export option
- Click the Export option
You will then be presented with a Save File diaglog box which allows you to choose the name and location where you want to save your settings.
Usage with Rich TerminalTheme
If you are using the Rich package and you want to save your console output to file with thes colors you can
from rich.console import TerminalTheme, Console
HTML_SAVE_THEME = TerminalTheme(
(0, 0, 0),
(199, 199, 199),
[(0, 0, 0),
(201, 27, 0),
(0, 194, 0),
(199, 196, 0),
(2, 37, 199),
(202, 48, 199),
(0, 197, 199),
(199, 199, 199),
(104, 104, 104)],
[(255, 110, 103),
(95, 250, 104),
(255, 252, 103),
(104, 113, 255),
(255, 119, 255),
(96, 253, 255),
(255, 255, 255)]
)
# create the Console instance with `record=True` to use the save methods
console = Console(record=True)
# ... console.print(...) usage to render text to screen
# now save the console output to an HTML file using the color theme
console.save_html('mytabledata.html', theme=HTML_SAVE_THEME)
Metadata
Release files for iterm2-colors2rgb 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| iterm2-colors2rgb-0.1.1.tar.gz | 8.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| iterm2_colors2rgb-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.6 kB
Release files / iterm2-colors2rgb-0.1.1.tar.gz
| Download URL | iterm2-colors2rgb-0.1.1.tar.gz |
|---|---|
| Size | 8.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3a6bb00b957fbcbe07c34c368b78aa9697a866b598a4e7092660a03a618246ef
|
|
BLAKE2b-256 checksum How to use checksums |
95eaac5d509fb8907764c34052c4375d5e760d0b24c8ec637f564d325b06494d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3
|
Release files / iterm2_colors2rgb-0.1.1-py3-none-any.whl
| Download URL | iterm2_colors2rgb-0.1.1-py3-none-any.whl |
|---|---|
| Size | 8.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cc44cdb22ee159e2742e4f036a3fd71831bc1274b911264e8d33f1f0aea358e9
|
|
BLAKE2b-256 checksum How to use checksums |
71e2844542db1061c841a7b8666f720d5808eefa50997193205296614c26f175
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3
|
Security for iterm2-colors2rgb 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.