Last updated: 2023-05-06
An increasing number of command-line software programs output text with
ANSI color
escape codes by default.
While some developers and users obviously prefer seeing these colors,
some users don’t.
Unfortunately, every new piece of software seems to have a
different way
of disabling colored text output and some software has no way at all.
Accepting the futility of trying to reverse this trend in 2017, an informal
standard was proposed:
Command-line software which adds ANSI color to its output by default should
check for aNO_COLOR
environment variable that, when present and not an empty
string (regardless of its value), prevents the addition of ANSI color.
By adopting this standard, users that prefer to have plain, non-colored text
output can export NO_COLOR=1
to their shell’s environment and automatically
disable color by default in all supported software.
If your software outputs color by default, please consider not doing so.
If you insist, please implement this standard to make it easy for your
users to disable color and then add your software to this list by
submitting a pull request.
If your software does not output color by default, you do not need to bother
with this standard.
Example Implementation
#include
#include
#include
int
main(int argc, char *argv[])
{
char *no_color = getenv("NO_COLOR");
bool color = true;
if (no_color != NULL && no_color[0] != ' ')
color = false;
/* do getopt(3) and/or config-file parsing to possibly turn color back on */
...
}
Frequently Asked Questions
-
Why not just set
$TERM
todumb
orxterm
without color support?
Or change all color definitions in the terminal to print the same color?The terminal is capable of color and should be able to print color when
instructed.
NO_COLOR
is a hint to the software running in the terminal to suppress
addition of color, not to the terminal to prevent any color from being
shown.It is reasonable to configure certain software such as a text editor to use
color or other ANSI attributes sparingly (such as the reverse attribute for
a status bar) while still desiring that other software not add color unless
configured to.
It should be up to the user whether color is used, not the software author. -
How should configuration files and command-line arguments be processed
in the presence of$NO_COLOR
?User-level configuration files and per-instance command-line arguments
should override$NO_COLOR
.
A user should be able to export$NO_COLOR
in their shell configuration
file as a default, but configure a specific program in its configuration
file to specifically enable color.This also means that software that can add color but doesn’t by default
does not need to care about$NO_COLOR
, because it will only ever be
adding color when instructed to do so (as it should be).
Color libraries supporting NO_COLOR
to disable default color output
Software using these libraries to output color inherently support disabling
color by default via NO_COLOR
.
Software directly supporting NO_COLOR
to disable color output by default
Software | Description | Date / Version Supported |
---|---|---|
alogview | Android logcat Filter | 2018-10-31 |
Ammonite | Scala Scripting | 2017-07-03 / 1.0.0 |
Ansible | IT automation system | 2021-04-26 / 2.11.0 |
Ansible Navigator | IT automation interface | 2021-10-13 / 1.1.0 |
Apt | Debian Package manager | 2021-10-10 / 2.3.11 |
Archey 4 | Python system information tool | 2020-09-26 / 4.8.0 |
Arduino CLI | Arduino command line tool | 2021-09-02 / 0.19.0 |
Aurornis | A library to simplify command line programs testing | 2021-11-16 / 1.2.0 |
Bashly | Bash command line framework and CLI generator | 2021-10-26 / 0.6.9 |
bat | A cat(1) clone with syntax highlighting and Git integration | 2020-10-02 / 0.16.0 |
beets | Music library manager and MusicBrainz tagger | 2019-05-30 / 1.4.9 |
bfs | Breadth-first version of the UNIX find command | 2019-05-06 / 1.4.1 |
Bikeshed | Spec/Document Processor | 2018-07-27 / 0.9 |
Bloop | Compilation/test server for Scala and Java | 2018-07-02 / 1.5.3 |
buildkit | Concurrent, cache-efficient, and Dockerfile-agnostic builder toolkit | 2022-07-20 |
Bullseye | A .NET library for running a target dependency graph | 2021-01-01 / 3.6.0 |
c-ray | The small C raytracer | 2021-09-24 |
Cake | A cross-platform build automation system with a C# DSL | 2021-03-06 / 1.1.0 |
CakePHP | Full stack framework for PHP | 2019-12-30 / 4.0.1 |
cdist | Usable configuration management | 2020-06-17 / 6.6.0 |
checkit | File integrity tool for Linux and Unix systems. | 2022-09-08 / 0.5.1 |
chezmoi | Manage dotfiles across multiple machines, securely | 2020-05-06 / 1.8.1 |
CliFM | The command line file manager | 2021-14-12 / 1.7 |
Clipboard | The cut, copy, and paste system for the terminal | 2022-12-04 / 0.1.2 |
Cras | Cras: The Anti-Procrastination Tool | 2020-06-05 / 0.1.0 |
Cronie | Cronie cron daemon project | 2021-03-19 / 1.6.1 |
csv2db | CSV database loading tool | 2019-09-23 / 1.4.0 |
DataLad | Data management and publication multitool | 2019-05-23 / 0.11.5 |
DDraceNetwork | Cooperative multiplayer game | 2022-02-27 / 5.1 |
debian-subsystem | Use Debian subsystem on other GNU/Linux distributions with desktop integration | 2021-11-09 |
DeepfakeHTTP | Web server that uses HTTP dumps as a source for responses | 2021-09-17 / 1.0.13 |
deno | Secure TypeScript runtime | 2019-02-09 / 0.2.11 |
Diun | Docker Image Update Notifier | 2021-05-26 / 4.17.0 |
elfinfo | Utility for displaying ELF information | 2020-01-17 / 1.0.1 |
Elixir | Dynamic, functional language | 2020-01-27 / 1.10.0 |
enum4linux-ng | Next generation enum4linux (Windows/Samba enumeration tool) | 2020-10-24 / 1.1.0 |
exa | A modern replacement for ls | 2021-12-06 |
F2 | Safe and fast cross-platform bulk-rename tool | 2021-05-04 / 1.5.7 |
fastlane | The easiest way to build and release mobile apps | 2020-11-19 / 2.168.0 |
fd | Simple, fast, and user-friendly alternative to find |
2020-03-22 / 7.5.0 |
ffind | Rust utility to find files and folders | 2018-03-24 |
forest-arborist | Manage a loosely coupled forest of git or hg repositories | 2018-04-15 / 1.2.0 |
fselect | Utility for finding files with SQL-like expressions | 2019-03-08 / 0.6.1 |
gatsby-cli | GatsbyJS command line interface | 2019-08-05 / 2.20.0 |
git-delete-merged-branches | Command-line tool to delete merged Git branches | 2020-06-29 / 1.2.0 |
git-subline-merge | Git merge driver for resolving conflicts | 2019-07-27 |
GitHub CLI | CLI for GitHub to manage pull requests, issues, and others | 2020-09-16 / 1.0.0 |
gocryptfs | Encrypted FUSE filesystem | 2021-12-11 / 2.3 |
gopass | Password store for teams | 2018-06-06 / 1.8.0 |
gplaces | A simple terminal based Gemini client | 2022-06-05 / 0.16.19 |
gwen | Automation and robotics for Gherkin | 2021-11-16 / 3.0.0 |
Hajime | Advanced Minecraft server wrapper | 2022-02-27 |
Homebrew | Package manager for macOS | 2018-02-27 / 1.5.5 |
Hspec | Testing framework for Haskell | 2021-05-12 / 1.8.1 |
htmltest | Tests generated HTML for issues | 2021-01-16 / 0.14.0 |
Hugo | Framework for building websites | 2022-06-16 / 0.101.0 |
Hurl | Run and test HTTP requests with plain text and curl | 2022-09-13 / 1.7.0 |
hx | Futuristic take on hexdump, made in Rust | 2020-11-22 / 0.4.0 |
inary | A package manager for SulinOS | 2021-10-18 |
irb | Official Ruby REPL | 2021-06-21 / 1.3.6 |
jc | Convert the output of popular command-line tools and file-types to JSON | 2021-12-07 / 1.17.4 |
jello | Filter JSON and JSON Lines data with Python syntax | 2021-12-08 / 1.5.0 |
KBSecret | Secret manager backed by Keybase and KBFS | 2018-04-13 / 1.4.0 |
kitten | Tiny multi-server automation tool | 2018-06-06 / 0.2.14 |
konch | Python shell/REPL configuration tool | 2019-01-19 / 4.0.0 |
lat | Fast fil |