Skip to content

Latest commit

 

History

History
293 lines (268 loc) · 36.5 KB

index.md

File metadata and controls

293 lines (268 loc) · 36.5 KB
layout
default

NO_COLOR

Last updated: {{ 'now' | date: "%Y-%m-%d" }}

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, an informal standard is hereby proposed:

Command-line software which adds ANSI color to its output by default should check for a NO_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 set one environment variable in their shell to have it automatically affect all supported software.

To add to this list of supported software, clone this site's Git repository and submit a pull request.

Example Implementation

#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>

int
main(int argc, char *argv[])
{
	char *no_color = getenv("NO_COLOR");
	bool color = true;

	if (no_color != NULL && no_color[0] != '\0') {
		color = false;
	}

	/* do getopt(3) and/or config-file parsing to possibly turn color back on */
	...
}

Frequently Asked Questions

  1. Why not just set $TERM to dumb or xterm 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.

  2. 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 via NO_COLOR.

Software Description Date/Version Supported
ansis NPM package for ANSI 256/truecolor styling of text in Node.js 2021-12-28 / 1.2.2
cfonts Rust and NPM package for colorful fonts in the console 2022-05-28 / 3.0.0
cli-color NPM package for colors and formatting 2019-10-09 / 2.0.0
click-extra Collection of utilities for Click, the Python CLI framework 2022-04-11 / 2.0.0
ColorDebug Colorful command line output C/C++ macros 2019-02-09
colored Rust crate for coloring terminal output 2019-01-05 / 1.7.0
Colorette Easily set your terminal text color & styles in Node.js 2021-09-17 / 2.0.0
colors-option NPM package for colors and formatting based on chalk 2021-03-02 / 1.0.0
console-ansi Easy console coloring and prefixing via Proxy object with ANSI strings (for JavaScript) 2022-06-14 / 1.3.0
crayon R package for colored terminal output 2018-02-08 / 1.5.1
crayon.js Modular Deno module and NPM package for terminal styling 2020-04-10 / 1.0.0
Dahlia A simple text formatting package, inspired by the game Minecraft 2022-09-24 / 2.0.0
Dye Cross-platform terminal styling for Swift command-line interface 2020-06-01 / 0.0.1
Fude Node.js library for terminal text style formatting 2022-06-29 / 3.0.0
Gapotchenko. FX.Console Virtual terminal functionality, console traits, and useful primitives for .NET console apps 2020-01-15 / 2020.1.15
gchalk Terminal string styling for Go with Windows 10 support 2021-10-06 / 1.1.1
Getopt::EX::Colormap Perl library for ANSI terminal color and command line option handling 2021-09-27 / 1.25.0
GNU libtextstyle Library for styling text output with CSS 2019-08-13 / 0.21
go-ansi Go Package for easy text formatting 2021-05-18 / 1.4.0
GraalVM Native Image Ahead-of-time compilation of Java code to standalone executables 2022-02-28 / 22.1.0
inquire A Rust library for building interactive prompts 2021-08-29 / 0.0.10
kleur A Node.js library for formatting terminal text with ANSI colors 2020-08-12 / 4.1.0
LogColor Python library for coloring output in log messages 2018-01-24 / 1.2.0
MatthiWare. CommandLineParser C# Command Line Parser Library 2020-07-21 / 0.3.1
Nano Colors Node.js library for formatting terminal text with ANSI colors 2021-09-21 / 0.1.0
paint Ruby gem for terminal colors and effects 2020-02-21 / 2.2.0
pastel Ruby gem for terminal output styling 2020-07-04 / 0.8.0
Pastel Tiny .NET library for coloring console output 2019-03-17 / 1.2.0
PyTermGUI A simple yet powerful Python TUI framework with a markup language, mouse support and more 2022-03-21 / 4.2.0
rich Python library for rich text and beautiful formatting 2022-02-08 / 11.2.0
sgr C++ stream manipulators for colored text output and more 2022-02-28
Spectre.Console A .NET library that makes it easier to create beautiful console applications 2020-07-21 / 0.1.0
Term::ANSIColor Perl library for color output using ANSI escape sequences 2020-01-17 / 5.01
termcolor Rust crate for cross platform terminal colors 2020-01-11 / 1.1.0
termcolor Python library for ANSI color formatting in the terminal 2022-09-11 / 2.0.0
termenv Go package for text styling, terminal detection and color conversions 2021-06-24 / 0.9.0
TextOutput Go package for controlling text output, using VT100 terminal codes 2019-11-18 / 1.9.1
textus_coloris C header library for colourised console output 2021-08-16
XConsole .NET console with coloring, pinning & positioning, stable for multitasking and 9000+ lines 2022-04-22 / 1.0.5
{: rules="groups"}

Software directly supporting NO_COLOR to disable default color output

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
lbt Friendly tools for interacting with the LBRY network 2022-03-31 / 2.1.2
lc Multi-dimensional, abbreviating ls/file lister in Nim 2019-11-18 / 0.9.1
LicensePlist License list generator for Apple developer 2022-09-20 / 3.23.3
Lintian Friendly packaging advice for Debian contributors 2021-12-12 / 2.114.87
lr File list generator 2018-01-29 / 1.5.1
lsd The next gen ls command 2022-01-16 / 0.21.0
mblaze Unix utilities to deal with Maildir 2018-01-29 / 1.2
meli Terminal mail client in Rust 2019-01-27 / 0.7.2
Meltano Data Ingestion, Transformation, and Management for Data Engineers 2022-11-08 / v2.9.0
Middleman Ruby-based static site generator 2019-02-18 / 5.0.0
mmCEsim Millimeter Wave Channel Estimation Simulation 2023-03-31 / 0.2.1
Modules Dynamic modification of one's environment 2020-04-07 / 4.5.0
mu Maildir indexer/searcher 2019-02-02 / 1.8.10
Nette Tester Testing library for PHP 2020-08-03 / 2.3.3
newsraft Feed reader for terminal 2022-08-14 / 0.8
NGLess Domain specific language for bioinformatics 2018-10-29 / 1.5.0
Nix The purely functional package manager 2021-11-01 / 2.4.0
nnn File manager 2020-04-05 / 4.6
npm Package manager for JavaScript 2018-03-24 / 5.8.0
nvh Node Version Helper 2018-08-04 / 4.1.0
o Small, fast, and limited text editor 2020-01-06 / 2.13.2
OCaml compiler The OCaml programming language compiler 2022-03-28 / 4.14.0
Octopus Deploy CLI Command Line Interface for Octopus Deploy 2022-11-23 / 0.6.0
opass Offer password suggestions 2021-06-12 / 0.9.1
ouch Painless CLI compression and decompression 2021-09-17 / 0.3.1
picocli Tiny Java command line interface 2019-01-05 / 3.9.0
pipewire PipeWire multimedia server 2021-03-13 / 0.3.24
Planck Stand-alone ClojureScript REPL 2019-05-19 / 2.23.0
procs Process and system query and formatting 2019-11-18 / 0.4.0
pulumi Programming-language-based IaC framework 2018-06-04 / 0.14.3
PyDERASN Python ASN.1 DER/CER/BER library 2018-02-14 / 3.1
pytest Python testing framework 2020-07-28 / 6.0.0
ripgrep Line-oriented search tool 2020-01-11 / 12.0.0
rsmodules Manage one's environment by the use of modulefiles 2018-10-09 / 0.7.3
Ruff An extremely fast Python linter, written in Rust 2023-08-09
Scipion CryoEM and CryoET image processing workflow engine 2022-07-07 / 3.0.22
ShellSpec A full-featured BDD unit testing framework for shell scripts 2020-06-21 / 0.25.0
shuffle Command line music player 2022-02-03 / 1.9.1
sjasmplus Z80/Z80N/GameBoy cross-assembler 2022-06-14 / 1.20.0
smenu Terminal selection filter 2018-02-05 / 1.0.0
Snow Testing library for C 2018-01-24 / 2.3.2
soupault Static website generator based on HTML rewriting 2021-07-19 / 3.0.0
sqlfmt Autoformatter for dbt SQL 2021-11-05 / 0.1.0
Symfony PHP framework and reusable components 2019-11-21 / 4.4.0
taoup Fortune implementation 2018-09-10 / 1.19
Tarantool In-memory computing platform 2021-10-19
TeaISO Live ISO generation tools for Debian, Arch Linux, Tearch and Sulin 2021-10-22
tealdeer TLDR pages client 2020-09-03 / 1.4.0
Telescope Gemini browser 2021-06-27 / 0.3
tree A recursive directory listing command 2022-12-26 / 2.1.0
twa Tiny web auditor with strong opinions 2018-11-15 / 1.1.0
txtnish Twtxt microblogging client 2018-08-31
undertime Timezone coordination tool 2018-06-06
whence Print URL a file was downloaded from 2020-06-20 / 0.9.2
woob Command-line applications to interact with many websites (banking, weather, video, etc.) 2021-05-13 / 3.1
xh Friendly and fast tool for sending HTTP requests 2021-02-28 / 0.8.0
xidoc A consistent and powerful markup language 2023-01-09 / 2023.1.9
xplr File manager 2021-04-15 / 0.4.4
zf A commandline fuzzy finder that prioritizes matches on filenames 2022-07-02 / 0.5
zoxide A smarter cd command 2020-03-05 / 0.1.0
{: rules="groups"}

Disabling color in software not supporting NO_COLOR

{:.two_col}

Software Method
Ammonite amm --color false (Docs)
Arcanist arc --no-ansi COMMAND (Docs)
Bundler bundle COMMAND --no-color (Docs)
Chalk export FORCE_COLOR=0 (Docs)
Clang -fno-color-diagnostics (Docs)
CMake Set CMAKE_COLOR_MAKEFILE to OFF (Docs)
Cocoapods pod COMMAND --no-ansi (Docs)
Composer composer --no-ansi (Docs)
FFmpeg export AV_LOG_FORCE_NOCOLOR=true (Docs)
fzf fzf --color=bw or export FZF_DEFAULT_OPTS=--color=bw (Docs)
GCC export GCC_COLORS= or -fno-diagnostics-color (Docs)
Git git config --global color.ui false (Docs)
GitHub gh config set prompt disabled (Docs)
GoAccess goaccess --no-color (Docs)
GStreamer export GST_DEBUG_NO_COLOR=true or --gst-debug-no-color (Docs)
luacheck luacheck --no-color (Docs)
Lynx lynx -nocolor (or show_color=never in .lynxrc)
Mercurial hg --color=never (or Docs for .hgrc)
Midnight Commander mc --nocolor
Packer export PACKER_NO_COLOR=true
Radare radare2 -e scr.color=0
RSpec export SPEC_OPTS=--no-color
Ruby (tests) export RUBY_TESTOPTS=--color=never
The Silver Searcher ag --nocolor (Rejected NO_COLOR Request)
Thor export THOR_SHELL=Basic (Docs)
util-linux touch /etc/terminal-colors.d/disable (Docs)
Vim vim '+set t_Co=0'
{: rules="groups"}