{"id":37063299,"url":"https://github.com/razbuild/raztint","last_synced_at":"2026-01-14T07:04:33.099Z","repository":{"id":329580557,"uuid":"1111937285","full_name":"razbuild/raztint","owner":"razbuild","description":"Lightweight cross-platform terminal colors and icons for Python CLIs.","archived":false,"fork":false,"pushed_at":"2025-12-20T18:59:16.000Z","size":204,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-12-22T17:11:55.840Z","etag":null,"topics":["ansi","cli","color","color-detection","cross-platform","fallback","icons","library","lightweight","nerd-fonts","python-library","terminal","terminal-colors","text-coloring","tty","unicode","utilities","zero-dependency"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/razbuild.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-07T22:48:10.000Z","updated_at":"2025-12-20T18:10:38.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/razbuild/raztint","commit_stats":null,"previous_names":["razbuild/raztint"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/razbuild/raztint","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/razbuild%2Fraztint","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/razbuild%2Fraztint/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/razbuild%2Fraztint/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/razbuild%2Fraztint/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/razbuild","download_url":"https://codeload.github.com/razbuild/raztint/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/razbuild%2Fraztint/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28412502,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T05:26:33.345Z","status":"ssl_error","status_checked_at":"2026-01-14T05:21:57.251Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansi","cli","color","color-detection","cross-platform","fallback","icons","library","lightweight","nerd-fonts","python-library","terminal","terminal-colors","text-coloring","tty","unicode","utilities","zero-dependency"],"created_at":"2026-01-14T07:04:32.516Z","updated_at":"2026-01-14T07:04:33.085Z","avatar_url":"https://github.com/razbuild.png","language":"Python","readme":"![Logo](https://raw.githubusercontent.com/razbuild/raztint/master/assets/logo.png)\n\n![GitHub License](https://img.shields.io/github/license/razbuild/raztint?logoColor=ffffff\u0026logoSize=auto\u0026label=License\u0026labelColor=1b1b1b\u0026color=ab0000\u0026cacheSeconds=3600)\n![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/razbuild/raztint/ci.yml?branch=master\u0026event=push\u0026logo=githubactions\u0026logoColor=ffffff\u0026logoSize=auto\u0026label=Build\u0026labelColor=1b1b1b\u0026color=ffc500\u0026cacheSeconds=3600)\n![Codecov](https://img.shields.io/codecov/c/github/razbuild/raztint?logo=codecov\u0026logoColor=ffffff\u0026logoSize=auto\u0026label=Coverage\u0026labelColor=1b1b1b\u0026color=0054e1\u0026cacheSeconds=3600)\n![PyPI - Version](https://img.shields.io/pypi/v/raztint?pypiBaseUrl=https%3A%2F%2Fpypi.org\u0026logo=pypi\u0026logoColor=ffffff\u0026logoSize=auto\u0026label=PyPi\u0026labelColor=1b1b1b\u0026color=ab0000\u0026cacheSeconds=3600)\n![Python Version from PEP 621 TOML](https://img.shields.io/python/required-version-toml?tomlFilePath=https%3A%2F%2Fraw.githubusercontent.com%2Frazbuild%2Fraztint%2Fmaster%2Fpyproject.toml\u0026logo=python\u0026logoColor=ffffff\u0026logoSize=auto\u0026label=Python\u0026labelColor=1b1b1b\u0026color=ffc500\u0026cacheSeconds=3600)\n\n---\n\n## Preview\n\nA zero-dependency Python library for ANSI coloring and smart CLI icons with automatic environment detection.\n\n| ASCII Icons | Nerd Font Icons | Unicode Icons |\n|------------|----------------|---------------|\n| ![ASCII](https://raw.githubusercontent.com/razbuild/raztint/master/assets/ascci.png) | ![Nerd Font](https://raw.githubusercontent.com/razbuild/raztint/master/assets/nerdfont.png) | ![Unicode](https://raw.githubusercontent.com/razbuild/raztint/master/assets/unicode.png) |\n\n---\n\nRazTint supports:\n- Zero Dependencies: Built entirely with the Python standard library.\n- Smart Icon Sets: Automatically degrades from **Nerd Fonts** → **Unicode** → **ASCII** based on the environment.\n- Automatic Detection: Detects `NO_COLOR`, `TERM`, and `isatty` to enable/disable features appropriately.\n- Windows Support: Automatically enables Virtual Terminal (VT) processing on Windows systems using `ctypes`.\n- Type Hinted: Fully typed for excellent IDE support and autocompletion.\n- Configurable: Granular control via Environment Variables.\n\nThis library is suitable for CLIs, logs, and tools that need portable, readable terminal output.\n\n---\n\n## Why RazTint?\n\nRazTint is intentionally minimal and zero-dependency.  \nIf you need a lightweight alternative to `colorama` or `rich` for:\n\n- Simple CLI tools\n- Scripts\n- Logging utilities\n- Cross-platform terminal output\n\nRazTint gives you:\n- Zero dependencies\n- Automatic icon fallback (Nerd → Unicode → ASCII)\n- Automatic color detection\n- Configurable behaviour with environment variables\n- Very small runtime overhead\n\n---\n\n## Features\n\n- Zero Dependencies: Built entirely with the Python standard library.\n\n- Smart Icon Sets: Automatically degrades from Nerd Fonts → Unicode → ASCII based on the environment.\n\n- Automatic Detection: Detects NO_COLOR, TERM, and isatty to enable/disable features appropriately.\n\n- Windows Support: Automatically enables Virtual Terminal (VT) processing on Windows systems using ctypes.\n\n- Type Hinted: Fully typed for excellent IDE support and autocompletion.\n\n- Configurable: Granular control via Environment Variables.\n\n---\n\n# Installation\n\n## From PyPI\n\n```bash\npip install raztint\n```\n\n## With pipx\n\n```bash\npipx install raztint\n```\n\n## From source\n\n```bash\ngit clone https://github.com/razbuild/raztint.git\ncd raztint\n\npip install -e .  # -e allows you to modify the source code in place\n```\n\n## How to install Nerd Font?\n\nTo install Nerd Fonts, visit the official [website](https://www.nerdfonts.com/font-downloads).\n\n---\n\n## Quick Start\n\nYou can import functions directly for quick usage, or instantiate the class for more control.\n\n### Functional Usage\n\nThe easiest way to use RazTint is importing the pre-instantiated helpers:\n\n```python\nfrom raztint import green, red, ok, err, info, warn\n\n# Coloring text\nprint(green(\"Success! The operation completed.\"))\nprint(red(\"Critical Error: Database not found.\"))\n\n# Using Icons (Auto-adapts to Nerd Font/Unicode/ASCII)\nprint(f\"{ok()} File saved successfully.\")\nprint(f\"{err()} Connection failed.\")\nprint(f\"{info()} Analysis in progress...\")\nprint(f\"{warn()} Disk space low.\")\n```\n\n### Class-based Usage\n\nUseful if you need to toggle color support dynamically within an application instance or want a scoped instance.\n\n```python\nfrom raztint import RazTint\n\ntint = RazTint()\n\n# Toggle features manually if needed\ntint.set_color(False) \n\nprint(tint.blue(\"This will be plain text now because color is disabled.\"))\n```\n\n### Using the `tint` Instance\n\n```python\nfrom raztint import tint\n\nprint(tint.red(\"text\"))\nprint(tint.ok(), \"hello\")\n```\n\n---\n## Icons \u0026 Detection\n\n### Icon Functions\n\n```python\nfrom raztint import ok, err, warn, info\n\nprint(ok(), \"Operation completed\")\nprint(err(), \"An error happened\")\nprint(warn(), \"Be careful\")\nprint(info(), \"For your information\")\n```\n\n### Icon Modes\nRazTint attempts to make your CLI look as good as possible by detecting the font capabilities of the terminal.\n\n| Mode | ok | err | warn | info | Condition |\n|------|----|-----|------|------|-----------|\n| Nerd |[󰄬] | [󰅖] | [󰈅] | [󰙎] | Detected Nerd Font via Env/Registry |\n| Std | [✓] | [✗] | [!] | [i] | UTF-8 supported, no Nerd Font |\n| ASCII | [OK] | [ERR] | [WARN] | [INFO] | Fallback |\n\n\u003e Note: Icons may not render correctly in GitHub preview depending on your browser font.\n\n### Detection Logic\n\nRazTint determines the best available icon and color mode using the following rules:\n\n1. Nerd Font Mode:\n   - Enabled if:\n     - `RAZTINT_USE_NERD_ICONS` environment variable is set to `1`, `true`, `yes`, or `on`, OR\n     - `NERDFONTS` or `NERD_FONTS` environment variable is set, OR\n     - `FONT_NAME` or `TERM_FONT` environment variable contains \"nerd\" or \"nf-\", OR\n     - A Nerd Font is detected via system checks:\n       - **Linux**: Uses `fc-list` (fontconfig) to check installed fonts\n       - **macOS**: Checks via `system_profiler` and font directories (`~/Library/Fonts`, `/Library/Fonts`)\n       - **Windows**: Checks `C:\\Windows\\Fonts` directory via PowerShell\n\n2. Standard Unicode Mode:\n   - Enabled when UTF-8 encoding is available AND\n   - `RAZTINT_NO_NERD_ICONS` is set (explicitly disables Nerd Fonts), OR\n   - Nerd Fonts are not detected and not forced via `RAZTINT_USE_NERD_ICONS`\n\n3. ASCII Mode:\n   - Used when:\n     - Output encoding is not UTF-8 (cannot encode Nerd Font or Unicode characters), OR\n     - System encoding test fails for Unicode characters\n\n---\n\n## Configuration\n\nYou can control **RazTint** behavior using environment variables. This is useful for CI/CD pipelines or user overrides.\n\n| Environment Variable | Value | Description |\n|----------------------|-------|-------------|\n| `NO_COLOR` | any | Disables all color output (standard specification). |\n| `RAZTINT_NO_COLOR` | any | Specific override to disable RazTint colors. |\n| `RAZTINT_FORCE_COLOR` | `1`, `true`, `yes`, `on` | Forces color output even if not a TTY. |\n| `RAZTINT_USE_NERD_ICONS` | `1`, `true`, `yes`, `on` | Forces the use of Nerd Font icons. |\n| `RAZTINT_NO_NERD_ICONS` | `1`, `true`, `yes`, `on` | Disables Nerd Font detection (falls back to Standard Unicode mode). |\n\n\n### Programmatically:\n```python\nfrom raztint import tint\ntint.set_color(False)\n```\n\n### Disable Colors\n\n```\nNO_COLOR=1\n```\n\n## Icon Behavior Configuration\n\n### Always Use Nerd Icons\n\n```\nRAZTINT_USE_NERD_ICONS=1\n```\n\n### Force-enable Colors\n\n```\nRAZTINT_FORCE_COLOR=1\n```\n\n### Disable Nerd Icons\n\n```\nRAZTINT_NO_NERD_ICONS=1\n```\n\n---\n\n# API Reference\n\n## Color Functions\n\nThe following functions return strings wrapped with ANSI styling when supported:\n\n- `black(text)`\n\n- `red(text)`\n\n- `green(text)`\n\n- `yellow(text)`\n\n- `blue(text)`\n\n- `magenta(text)`\n\n- `cyan(text)`\n\n- `white(text)`\n\n- `gray(text)`\n\nInternally, these use `tint.color()`.\n\n---\n\n## Icon Functions\n\nThese return appropriate status symbols based on environment detection:\n\n- `ok()` - Returns a success icon (green checkmark)\n\n- `err()` - Returns an error icon (red cross)\n\n- `warn()` - Returns a warning icon (yellow exclamation)\n\n- `info()` - Returns an info icon (blue 'i')\n\nRazTint selects the best available style in this order:\n1. Nerd Font icons (if installed)\n2. Unicode icons (if UTF-8 is supported)\n3. ASCII fallback\n\n---\n\n## RazTint Class Methods\n\nWhen using the `RazTint` class directly, you have access to additional methods:\n\n### `color(text: str, fg_code: str) -\u003e str`\n\nLow-level method to apply ANSI color codes to text. Returns the text with ANSI escape sequences when color is enabled, otherwise returns plain text.\n\n**Parameters:**\n- `text`: The text to colorize\n- `fg_code`: ANSI color code (e.g., \"31\" for red, \"32\" for green)\n\n**Example:**\n```python\nfrom raztint import RazTint\n\ntint = RazTint()\ncolored = tint.color(\"Hello\", \"31\")  # Red text\n```\n\n### `set_color(enabled: bool) -\u003e None`\n\nEnable or disable color output programmatically.\n\n**Parameters:**\n- `enabled`: `True` to enable colors, `False` to disable\n\n**Example:**\n```python\nfrom raztint import RazTint\n\ntint = RazTint()\ntint.set_color(False)  # Disable colors\nprint(tint.red(\"This will be plain text\"))\n```\n\n## RazTint Class Attributes\n\n### `use_color: bool`\n\nBoolean indicating whether color output is currently enabled. This is automatically set based on environment detection but can be modified via `set_color()`.\n\n### `icon_mode: str`\n\nCurrent icon mode being used. Possible values:\n- `\"nerd\"` - Nerd Font icons\n- `\"std\"` - Standard Unicode icons\n- `\"ascii\"` - ASCII fallback icons\n\n---\n\n# Automatic Behavior\n\nRazTint intelligently detects and adapts to the environment:\n\n## Color Detection\n\nColor support is determined by checking (in order):\n1. `NO_COLOR` or `RAZTINT_NO_COLOR` environment variables (disables colors)\n2. `RAZTINT_FORCE_COLOR` environment variable (forces colors)\n3. Whether output is connected to a TTY (`sys.stdout.isatty()`)\n4. On Windows: Attempts to enable Virtual Terminal processing\n5. `TERM` environment variable (must not be \"dumb\")\n\nIf color is not supported, all color functions return plain text.\n\n## Icon Detection\n\nIcon mode is determined by checking (in order):\n1. Encoding capability (can the system encode Nerd Font characters?)\n2. `RAZTINT_USE_NERD_ICONS` or `RAZTINT_NO_NERD_ICONS` environment variables\n3. System-level Nerd Font detection (see Detection Logic section)\n4. Falls back to Standard Unicode or ASCII based on encoding support\n\nIf unsupported, RazTint transparently falls back to non-colored text and simpler icons.\n\n---\n\n# License\n\nMIT License\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frazbuild%2Fraztint","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frazbuild%2Fraztint","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frazbuild%2Fraztint/lists"}