Skip to main content

bruhcolor

Named and 256-color terminal text formatting for Python. No runtime dependencies. The companion formatter used by bruhanimate.

Requires Python 3.10 or newer. Development uses Python 3.13 and uv 0.13.4.

python -m pip install bruhcolor
from bruhcolor import bruhcolored

message = bruhcolored("Hello world!", color="red", on_color=194, attrs=["bold"])
print(message)
print(message.colored)  # ANSI string
print(message.text)     # original text
assert len(message) == 12

Foreground/background accept named colors or integers/numeric strings from 0 through 255, including zero (black). Named colors include black, red, green, yellow, blue, magenta, cyan, light_grey, dark_grey, light_red, light_green, light_yellow, light_blue, light_magenta, light_cyan and white; grey aliases black. Attributes: bold, dark, italic, underline, blink, reverse, concealed, crossed-out. Unknown colors/attributes are ignored for compatibility.

from bruhcolor import bruhcolored, colors, color_codes, valid_effects

label = bruhcolored("Ready", color=46)
print(f"{label:>12}")
assert label[:2] == "Re"
assert (label + "!").text == "Ready!"
assert (label * 2).text == "ReadyReady"
color_codes()
valid_effects()
colors(support="full")

Alignment supports a width and optional <, > or ^; length/indexing count Python characters, not terminal display cells. Slices return plain strings. Set ANSI_COLORS_DISABLED (any value) to disable all generated escape sequences. Imports and formatting do not print or open a terminal; only discovery helpers print.

Development

python -m pip install uv==0.13.4
uv sync --locked --python 3.13
uv run --locked ruff check .
uv run --locked mypy
uv run --locked pytest
uv run --locked python scripts/check_examples.py
uv run --locked python publish.py --check

uv.lock pins repository/CI environments. poetry-core is only the build backend; the Poetry CLI is not used. The former poetry.lock is superseded by uv.lock. The package keeps no runtime dependencies. CI covers Python 3.13 on Linux, Windows and macOS, plus the minimum Python 3.10 on Linux.

Releases

Develop on a feature/dev branch, merge reviewed changes into main, then explicitly push a matching vMAJOR.MINOR.PATCH tag when ready to publish. Main pushes run checks; they do not publish. See the release guide.

publish.py previews by default. --check validates the current version; --write bumps source versions and refreshes the lockfile. Git writes require additional explicit flags. The helper never creates a release tag or uploads. Legacy ignored publish.ps1/push_version.py are not part of this workflow.

Formatting corrections

The current working version fixes integer zero being treated as an absent color, removes the duplicate escape prefix from indexed backgrounds, and emits no reset when colors are disabled. Unsupported wrapper addition raises TypeError instead of printing and returning None. Metadata now declares Python >=3.10, matching the union annotations already used by the package. These corrections are covered by regression tests; the existing version number has not been bumped or published.

License

MIT. See LICENSE and retained upstream attribution in COPYING.txt.

RGB colors, color control, and formatting

bruhcolored accepts palette indexes/names, #RRGGBB, and (r, g, b) tuples. RGB channels must be integers from 0 through 255. Invalid explicit hex/RGB values raise ValueError; unknown legacy color names retain their existing behavior.

from bruhcolor import bruhcolored

color = bruhcolored('hello', color='#66ccff', on_color=(12, 20, 30), enabled=True)
assert '38;2;102;204;255' in str(color)
assert format(bruhcolored('hello', enabled=False), '*^9.3s') == '***hel***'

Use enabled=False for plain output or enabled=True to explicitly enable color. With enabled=None (the default), a present ANSI_COLORS_DISABLED or nonempty NO_COLOR disables styling. There is no terminal probing or automatic RGB fallback. Formatting supports Python string fill/alignment, width, precision and optional s; precision preserves color spans and resets styling before padding. Widths and precision count Python characters, not terminal display cells. Wide and combining characters therefore need application-level display-width handling. These additions are available starting with bruhcolor 0.0.67.

Metadata

Release files for bruhcolor 0.0.67

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bruhcolor 0.0.67
File Size Uploaded Provenance Actions
bruhcolor-0.0.67.tar.gz 7.1 kB With provenance Details for bruhcolor-0.0.67.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bruhcolor 0.0.67
File Interpreter ABI Platform Actions
bruhcolor-0.0.67-py3-none-any.whl Python 3 none any Details for bruhcolor-0.0.67-py3-none-any.whl

Total release size: 15.9 kB

Release files / bruhcolor-0.0.67.tar.gz

Download URL bruhcolor-0.0.67.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
8ed56ead1641dce7c63ec014469a626eb7ecf98fe2424e4b63d0f5282bf25df5
BLAKE2b-256 checksum
How to use checksums
99e03e8867be56ca2090c396c15208d224e8320dbd0b96890203cbc590095abb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

Release files / bruhcolor-0.0.67-py3-none-any.whl

Download URL bruhcolor-0.0.67-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9db76fadd875db9ada97f7e1b48f6490d6152b17c62952bd84018b089c06630a
BLAKE2b-256 checksum
How to use checksums
a7641d74edd1d74556718d4ee9562079f494d4eff2b6281f910fb12836c079a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

Security for bruhcolor 0.0.67

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for bruhcolor-0.0.67.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.0.67 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page