TermTint
A lightweight, zero-dependency Python library for simple colored and styled terminal output.
Why TermTint?
Normally, Python prints unstyled plain text in your terminal:
print("Success!")
If you want colored output, writing raw ANSI escape sequences manually can quickly make your code hard to read:
print("\033[32mSuccess!\033[0m")
TermTint solves this by providing a clean, simple, zero-dependency interface for colored terminal text without the overhead of heavy CLI frameworks:
from termtint import colored
print(colored("Success!", "green"))
Features
- Zero Runtime Dependencies: Uses only the Python standard library.
- 8 Foreground Colors & 4 Text Styles: Simple, predictable ANSI styling.
- Modern Windows Support: Native Virtual Terminal support on Windows 10/11.
- NO_COLOR Compliant: TermTint respects
NO_COLORin automatic mode. - Redirect & Stream Aware: TermTint automatically avoids adding ANSI escape sequences when output is redirected to a file or pipe.
- Convenience Helpers: Direct
print_green(),print_red(), and other function helpers. - Ultra-Lightweight: Minimal runtime overhead and simple code structure.
Installation
Install TermTint via PyPI using pip:
pip install termtint
Quick Start
from termtint import colored, print_green, print_red, print_yellow
# Simple string coloring
print(colored("Operation succeeded", "green"))
print(colored("Disk space low", "yellow", style="bright"))
print(colored("Database error", "red", style="underline"))
# Convenience print functions
print_green("System online")
print_yellow("Deprecated feature warning")
print_red("Fatal crash occurred!")
Supported Colors
TermTint supports 8 standard terminal foreground colors:
| Color | Value | Code Example |
|---|---|---|
black |
Black | colored("text", "black") |
red |
Red | colored("text", "red") |
green |
Green | colored("text", "green") |
yellow |
Yellow | colored("text", "yellow") |
blue |
Blue | colored("text", "blue") |
magenta |
Magenta | colored("text", "magenta") |
cyan |
Cyan | colored("text", "cyan") |
white |
White | colored("text", "white") |
Invalid color names raise a ValueError with a helpful error message.
Supported Styles
TermTint supports 4 essential text styles:
| Style | Description | Code Example |
|---|---|---|
normal |
Default normal weight | colored("text", "green", style="normal") |
bright |
Bold / bright weight | colored("text", "green", style="bright") |
dim |
Faded / lower intensity | colored("text", "white", style="dim") |
underline |
Underlined text | colored("text", "blue", style="underline") |
Convenience Print Functions
In addition to colored(), TermTint provides direct print functions for fast CLI output:
from termtint import (
print_black,
print_red,
print_green,
print_yellow,
print_blue,
print_magenta,
print_cyan,
print_white,
)
print_green("Success message")
print_red("Error message", style="bright")
print_yellow("Warning message", style="underline")
All convenience functions support standard Python print() keyword arguments: sep, end, file, and flush.
Enabling & Disabling Colors
By default, TermTint uses automatic terminal detection. You can explicitly force or disable colors programmatically:
from termtint import enable_color, disable_color, reset_color_state, colored
# Force colors ON (e.g. CLI --color=always flag)
enable_color()
print(colored("Always colored", "cyan"))
# Force colors OFF (e.g. CLI --no-color flag)
disable_color()
print(colored("Plain text only", "cyan")) # Output: "Plain text only"
# Reset back to automatic detection
reset_color_state()
Automatic Terminal & Stream Detection
TermTint automatically detects terminal capabilities using a multi-step check:
- Explicit Toggle: Respects programmatic
enable_color()ordisable_color(). NO_COLORVariable: TermTint respectsNO_COLORin automatic mode (no-color.org).FORCE_COLORVariable: IfFORCE_COLOR=1, colors are forced on in automatic mode.- Destination Stream & TTY Check: If output is redirected (e.g.
python script.py > output.txt) or a file-like stream is supplied (file=f), ANSI escape sequences are avoided automatically. - Dumb Terminal Check: If
TERM=dumb, colors are disabled.
Windows Support
On Windows 10 and 11, TermTint automatically enables Virtual Terminal (VT) processing using standard-library ctypes bindings to the Win32 Console API. If VT mode cannot be enabled, TermTint safely falls back to plain text without crashing.
Colorama Comparison
TermTint is a focused, lightweight alternative for developers who primarily need simple colored terminal output, whereas Colorama provides broader historical ANSI translation.
| Feature / Goal | TermTint | Colorama |
|---|---|---|
| Runtime Dependencies | Zero (Standard Library) | External package |
| Primary Goal | Lightweight colored output | Legacy ANSI translation |
| API Style | Clean functional API | Module constants & stream wrappers |
stdout Patching |
Avoided (pure string format) | Global stream wrapping option |
| Modern Windows 10/11 | Native VT API | Supported |
NO_COLOR Standard |
Supported in auto mode | Not native |
Limitations
TermTint is intentionally small and focused. It is not a full terminal UI framework:
- No progress bars or spinners
- No table or layout formatters
- No cursor movement or screen clearing
- No markdown or syntax highlighting
If you require full TUI widgets or complex terminal graphics, consider tools like Rich or Textual.
Development
Set up TermTint locally:
git clone https://github.com/hasheramin5-cyber/TermTint.git
cd TermTint
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\Activate.ps1
pip install -e ".[dev]"
Run tests and linters:
# Run test suite
pytest
# Run linter
ruff check .
# Run micro-benchmarks
python benchmarks/benchmark.py
Documentation
Full documentation is available in the docs/ directory:
License
TermTint is licensed under the MIT License.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file termtint-0.1.0.tar.gz.
File metadata
- Download URL: termtint-0.1.0.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33a0760ac59a471ab887cb5b857a09efea3bcb82f0d925ac195031ceef191358
|
|
| MD5 |
ffe6903297ad0f2294bc829751c3d042
|
|
| BLAKE2b-256 |
ba4832cd2fa801e17279564f135d269cfef1b759a053668abd1d80d9d5c4c540
|
Provenance
The following attestation bundles were made for termtint-0.1.0.tar.gz:
Publisher:
publish.yml on hasheramin5-cyber/TermTint
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
termtint-0.1.0.tar.gz -
Subject digest:
33a0760ac59a471ab887cb5b857a09efea3bcb82f0d925ac195031ceef191358 - Sigstore transparency entry: 2755013879
- Sigstore integration time:
-
Permalink:
hasheramin5-cyber/TermTint@c0742c4f689e479b611ec5675c0715e19acbdbb5 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/hasheramin5-cyber
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c0742c4f689e479b611ec5675c0715e19acbdbb5 -
Trigger Event:
release
-
Statement type:
File details
Details for the file termtint-0.1.0-py3-none-any.whl.
File metadata
- Download URL: termtint-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e45afda237c2cbbfae578f76edd237284fd51017c7f35bdf72e516c3c9d4b40
|
|
| MD5 |
85d11985f37bf5db5fe49b67957b31e3
|
|
| BLAKE2b-256 |
eab5c2074f4746582f6a52ddd4f5a418067cfc8c741e99b29779b04b821132ff
|
Provenance
The following attestation bundles were made for termtint-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on hasheramin5-cyber/TermTint
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
termtint-0.1.0-py3-none-any.whl -
Subject digest:
8e45afda237c2cbbfae578f76edd237284fd51017c7f35bdf72e516c3c9d4b40 - Sigstore transparency entry: 2755014741
- Sigstore integration time:
-
Permalink:
hasheramin5-cyber/TermTint@c0742c4f689e479b611ec5675c0715e19acbdbb5 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/hasheramin5-cyber
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c0742c4f689e479b611ec5675c0715e19acbdbb5 -
Trigger Event:
release
-
Statement type: