{"id":50900882,"url":"https://github.com/gurgeous/zig-supports-color","last_synced_at":"2026-06-16T02:30:47.839Z","repository":{"id":352720723,"uuid":"1215338497","full_name":"gurgeous/zig-supports-color","owner":"gurgeous","description":"a small, zero-allocation library that detects ANSI color support in the terminal","archived":false,"fork":false,"pushed_at":"2026-04-20T20:09:02.000Z","size":11,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-06T05:41:23.843Z","etag":null,"topics":["ansi","cli","term","tui","zig"],"latest_commit_sha":null,"homepage":"","language":"Zig","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/gurgeous.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":"supports_color.zig","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-04-19T19:35:19.000Z","updated_at":"2026-05-01T08:22:33.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/gurgeous/zig-supports-color","commit_stats":null,"previous_names":["gurgeous/zig-supports-color"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gurgeous/zig-supports-color","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gurgeous%2Fzig-supports-color","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gurgeous%2Fzig-supports-color/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gurgeous%2Fzig-supports-color/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gurgeous%2Fzig-supports-color/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gurgeous","download_url":"https://codeload.github.com/gurgeous/zig-supports-color/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gurgeous%2Fzig-supports-color/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34388669,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-16T02:00:06.860Z","response_time":126,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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","term","tui","zig"],"created_at":"2026-06-16T02:30:47.288Z","updated_at":"2026-06-16T02:30:47.834Z","avatar_url":"https://github.com/gurgeous.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![test](https://github.com/gurgeous/zig-supports-color/actions/workflows/ci.yml/badge.svg)](https://github.com/gurgeous/zig-supports-color/actions/workflows/ci.yml)\n\n# zig-supports-color\n\nA small, zero-allocation library that detects ANSI color support in the terminal. Built on Zig 0.16.\n\n### Usage\n\n```zig\n//\n// Returns:\n//\n// .none    - no support for color\n// .ansi    - basic 16 color palette (often customized)\n// .ansi256 - standard 256 color palette\n// .ansi16m - 16m rgb (\"truecolor\"), the modern standard\n//\n\n// look at env\nconst level = supports_color.onEnv(init.environ_map);\n\n// or try stdout, stderr, dev/tty. checks if the file is a tty\nconst level = try supports_color.onStdout(init.io, init.environ_map);\nconst level = try supports_color.onStderr(init.io, init.environ_map);\nconst level = try supports_color.onDevTty(init.io, init.environ_map);\n```\n\n### Installation\n\n```sh\n# fetch and add to build.zig.zon\nzig fetch --save git+https://github.com/gurgeous/zig-supports-color.git\n```\n\nEdit your `build.zig`:\n\n```zig\nconst dep = b.dependency(\"supports_color\", .{ .target = target, .optimize = optimize });\nmain.root_module.addImport(\"supports_color\", dep.module(\"supports_color\"));\n```\n\n### Details\n\nWe rely primarily on $TERM and $COLORTERM, and honor $NO_COLOR/$FORCE_COLOR if truthy. We look at $CI and friends as well. This is [surprisingly complicated](https://github.com/gurgeous/zig-supports-color/blob/main/supports_color.zig).\n\nSpecial thanks to these libraries which provided the basis for `zig-supports-color`. My work is essentially a zig-friendly variant of these, with some effort made to remove outdated heuristics:\n\n- [BurntSushi/termcolor](https://github.com/BurntSushi/termcolor) (rust)\n- [chalk/supports-color](https://github.com/chalk/supports-color) (ts)\n- [charmbracelet/colorprofile](https://github.com/charmbracelet/colorprofile) (go)\n- [crossterm-rs/crossterm](https://github.com/crossterm-rs/crossterm) (rust)\n- [muesli/termenv](https://github.com/muesli/termenv) (go)\n- [rust-cli/anstyle](https://github.com/rust-cli/anstyle) (rust)\n\nAlso see this delightful ncurses terminfo doc:\n\n- https://invisible-island.net/ncurses/terminfo.src.html\n\n### Changelog\n\n**0.1.0 (unreleased)**\n\n- initial announcement\n\n### Future Work\n\nI will be using this in my cli projects, though I consider it beta quality. In particular [tennis](https://github.com/gurgeous/tennis), which people want to use on older terminals that don't support truecolor. Feel free to create issues/PRs, feedback always welcome.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgurgeous%2Fzig-supports-color","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgurgeous%2Fzig-supports-color","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgurgeous%2Fzig-supports-color/lists"}