0

NO_COLOR

 2 years ago
source link: https://no-color.org/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

NO_COLOR

Last updated: 2021-06-12

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, many 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:

All command-line software which outputs text with ANSI color added should check for the presence of a NO_COLOR environment variable that, when present (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.

This website will document which software has adopted this standard and when support was added. For software that has not or will not adopt this standard, an attempt will be made to document how to otherwise disable color.

To add software to this site, clone this site’s Git repository and submit a pull request.

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 black?

    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 cli-color NPM package for colors and formatting 2019-10-09 / 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 colors-option NPM package for colors and formatting based on chalk 2021-03-02 / 1.0.0 crayon R package for colored terminal output 2018-02-08 Dye Cross-platform terminal styling for Swift command-line interface 2020-06-01 / 0.0.1 Gapotchenko. FX.Console Virtual terminal functionality, console traits, and useful primitives for .NET console apps 2020-01-15 / 2020.1.15 kleur A Node.js library for formatting terminal text with ANSI colors 2020-08-12 / 4.1.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 LogColor Python library for coloring output in log messages 2018-01-24 MatthiWare. CommandLineParser C# Command Line Parser Library 2020-07-21 / 0.3.1 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 Core library for coloring console output 2019-03-17 / 1.2.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 TextOutput Go package for controlling text output, using VT100 terminal codes 2019-11-18 / 1.9.1

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 Archey 4 Python system information tool 2020-09-26 / 4.8.0 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 Bloop Compilation/test server for Scala and Java 2018-07-02 Bullseye A .NET library for running a target dependency graph 2021-01-01 / 3.6.0 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 chezmoi Manage dotfiles across multiple machines, securely 2020-05-06 / 1.8.1 Cras Cras: The Anti-Procrastination Tool 2020-06-05 / 0.1.0 Cronie Cronie cron daemon project 2021-03-19 csv2db CSV database loading tool 2019-09-23 / 1.4.0 DataLad Data management and publication multitool 2019-05-23 / 0.11.5 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 enum4linux-ng Next generation enum4linux (Windows/Samba enumeration tool) 2020-10-24 Elixir Dynamic, functional language 2020-01-27 / 1.10.0 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 git-delete-merged-branches Command-line tool to delete merged Git branches 2020-06-29 / 1.2.0 GitHub CLI CLI for GitHub to manage pull requests, issues, and others 2020-09-16 git-subline-merge Git merge driver for resolving conflicts 2019-07-27 gopass Password store for teams 2018-06-06 / 1.8.0 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 hx Futuristic take on hexdump, made in Rust 2020-11-22 / 0.4.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 lc Multi-dimensional, abbreviating ls/file lister in Nim 2019-11-18 lr File list generator 2018-01-29 mblaze Unix utilities to deal with Maildir 2018-01-29 meli Terminal mail client in Rust 2019-01-27 Middleman Ruby-based static site generator 2019-02-18 Modules Dynamic modification of one’s environment 2020-04-07 / 4.5.0 mu Maildir indexer/searcher 2019-02-02 Nette Tester Testing library for PHP 2020-08-03 / 2.3.3 NGLess Domain specific language for bioinformatics 2018-10-29 nnn File manager 2020-04-05 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 opass Offer password suggestions 2021-06-12 / 0.9.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 pulumi Programming-language-based IaC framework 2018-06-04 / 0.14.3 PyDERASN Python ASN.1 DER/CER/BER library 2018-02-14 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 ShellSpec A full-featured BDD unit testing framework for shell scripts 2020-06-21/ 0.25.0 smenu Terminal selection filter 2018-02-05 Snow Testing library for C 2018-01-24 Symfony PHP framework and reusable components 2019-11-21 / 4.4.0 taoup Fortune implementation 2018-09-10 tealdeer TLDR pages client 2020-09-03 / 1.4.0 txtnish Twtxt microblogging client 2018-08-31 twa Tiny web auditor with strong opinions 2018-11-15 / 1.1.0 undertime Timezone coordination tool 2018-06-06 whence Print URL a file was downloaded from 2020-06-20 / 0.9.2 xh Friendly and fast tool for sending HTTP requests 2021-02-28 / 0.8.0 xplr File manager 2021-04-15 / 0.4.4

Disabling color in software not supporting NO_COLOR

Software Method Ammonite amm --color false (Docs) Ansible export ANSIBLE_NOCOLOR=true (Docs) Arcanist arc --no-ansi COMMAND (Docs) Bundler bundle COMMAND --no-color (Docs) Clang -fno-color-diagnostics (Docs) Cocoapods pod COMMAND --no-ansi (Docs) FFmpeg export AV_LOG_FORCE_NOCOLOR=true 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) GStreamer export GST_DEBUG_NO_COLOR=true or --gst-debug-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 export RUBY_TESTOPTS=--color=never Ruby IRB echo "IRB.conf[:USE_COLORIZE] = false" >> ~/.irbrc (Docs) 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'


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK