Live data from Hacker News

No_color: Disabling ANSI color output by default

no-color.org

11–17 of 17 posts

Re: No_color: Disabling ANSI color output by default

#11

Hmm, why not. Though most of the software do the right thing by checking if the standard output is an actual tty (isatty) to avoid colors when redirecting to something else (e.g. socket, fifo, etc). The name NO_COLOR suggests a really binary choice which may be okay. Though GNU coreutils usually have a more selective option like --color=always|auto|never. I'd prefer supporting a more general COLORS=on|off|compatible|…

Yeah, my first thought on seeing this was that I really want a way to force color just as easily; when I output diffs in CI, they're much more readable with color but it's a pain to enable it when running headless.

Re: No_color: Disabling ANSI color output by default

#12

Does NO_COLOR=1 mean that all ANSI formatting should be disabled? Including bold text, italic text, and so on? It seems that different software handles that question in different ways.

I asked the author a while back. They said it purely relates to colour. Not other styles. Alas, they removed the issues and there is no record of that.

Re: No_color: Disabling ANSI color output by default

#13

Hmm, why not. Though most of the software do the right thing by checking if the standard output is an actual tty (isatty) to avoid colors when redirecting to something else (e.g. socket, fifo, etc). The name NO_COLOR suggests a really binary choice which may be okay. Though GNU coreutils usually have a more selective option like --color=always|auto|never. I'd prefer supporting a more general COLORS=on|off|compatible|…

Yeah, my first thought on seeing this was that I really want a way to force color just as easily; when I output diffs in CI, they're much more readable with color but it's a pain to enable it when running headless.

I'd argue that if somebody implements NO_COLOR support they will likely also implement a --color switch to force color.

At least I do. :)

Post reply on HN