TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

No_color

466 pointsby ducaaleabout 3 years ago

37 comments

gregmacabout 3 years ago
&gt; 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?<p>&gt; 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.<p>I have to admit I don&#x27;t really get this. I personally like colorized output, and I can&#x27;t even think of situations where the colors chosen by a developer were so bad I wanted to disable them completely.<p>I respect others like no color (and there&#x27;s already a solution per that, above), but I don&#x27;t quite get the desire to have just <i>some</i> color (prompts but not applications). Can someone with this opinion explain their rationale?<p>Normally I wouldn&#x27;t care, -- individual preferences are like opinions and everyone is entitled to their own -- but this imposes work on every developer&#x2F;application. There&#x27;s certainly ways to implement this that minimize impact, but it&#x27;s still a non-zero up-front and ongoing maintenance&#x2F;testing cost.
评论 #30483972 未加载
评论 #30486516 未加载
评论 #30484728 未加载
评论 #30484373 未加载
评论 #30485256 未加载
评论 #30484214 未加载
评论 #30484392 未加载
评论 #30485378 未加载
评论 #30484223 未加载
评论 #30484644 未加载
评论 #30485206 未加载
评论 #30488219 未加载
评论 #30486138 未加载
评论 #30486643 未加载
评论 #30484543 未加载
评论 #30484081 未加载
评论 #30487320 未加载
评论 #30484999 未加载
评论 #30486986 未加载
评论 #30486144 未加载
评论 #30488084 未加载
评论 #30486080 未加载
评论 #30484328 未加载
评论 #30486003 未加载
评论 #30487219 未加载
评论 #30487182 未加载
评论 #30484006 未加载
colordropsabout 3 years ago
I&#x27;m starting to be of the mind that environment variables in general are an anti-pattern. They have arbitrary scope, their lifetime is not clear, and they are not easily composable. This was not something that bothered me so acutely until I started using declarative config with NixOS to configure my system, and found environment variables to be a big wart on this.
评论 #30485761 未加载
评论 #30485330 未加载
评论 #30485519 未加载
alrsabout 3 years ago
For tools that don&#x27;t honor NO_COLOR, I have a filter called nofun, which gets rid of color and animations.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;alrs&#x2F;nofun" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;alrs&#x2F;nofun</a>
评论 #30484705 未加载
评论 #30486623 未加载
评论 #30485189 未加载
评论 #30484097 未加载
rsyncabout 3 years ago
I think this is a fine idea but I wonder about this part:<p>&quot;... should check for the presence of a NO_COLOR environment variable that, when present (<i>regardless of its value</i>), prevents the addition of ANSI color ...&quot;<p>How common is this behavior ?<p>That is, the presence of the env var <i>regardless of its value</i> trips the conditional ?<p>That seems like asking for trouble &#x2F; confusion ... especially since there is a very well understood practice of setting 0&#x2F;1 false&#x2F;true for settings like this.<p>Is this commonly done and I have just never noticed it ?
评论 #30484027 未加载
评论 #30484056 未加载
评论 #30484693 未加载
cturtleabout 3 years ago
One question this leaves me with is regarding other ANSI escapes. Would a user with NO_COLOR be okay with bold, invert, italic, underline, or other effects? I’m happy to add support for NO_COLOR to the tool I maintain, but I think this proposal should be more clear in this regard.<p>I would assume that COLOR implies that only color escapes should be disabled, but the description also mentions “plain” output.
评论 #30485979 未加载
brandonbloomabout 3 years ago
Competing standard for CLICOLOR and CLICOLOR_FORCE variables that have some support: <a href="https:&#x2F;&#x2F;bixense.com&#x2F;clicolors&#x2F;" rel="nofollow">https:&#x2F;&#x2F;bixense.com&#x2F;clicolors&#x2F;</a>
评论 #30486515 未加载
bin_bashabout 3 years ago
While this is a good standard, I often find myself just doing `somecommand | cat` whenever I want to get rid of colors. Usually they&#x27;re disabled when outputting to a non-tty device.
obeattieabout 3 years ago
Without understanding the minutiae of this, couldn’t someone just write a program that we can pipe any output to, which strips colour commands from its input before writing it back out? Does such a program already exist? That wouldn’t require every program to add support for an environment variable.
评论 #30486661 未加载
评论 #30487127 未加载
评论 #30487392 未加载
jagger27about 3 years ago
Definitely adding this to my todo list to add to the CLI tools I help maintain. A lot of modern tools add emojis to output as well, which I sometimes find unnecessary in a similar way to terminal colours.<p>NO_COLOR and NO_EMOJI seem reasonable. Any other ideas?
Taniwhaabout 3 years ago
Oh yes! I am so over programs that output yellow text into a terminal with a white background and somehow expect people to be able to read the result
评论 #30484074 未加载
评论 #30484842 未加载
xg15about 3 years ago
I agree that an env variable would be &quot;philosophically&quot; the right thing to do (&quot;no colors&quot; is a user choice and programs should respect user choices).<p>However, giving a standard enough momentum so that most developers will actually implement it is an incredibly hard thing to do. I honestly don&#x27;t have much hope that this will reach enough projects to be practically usable. At least not without support&#x2F;enforcement by distributions.<p>I also think that modifying shells instead could be a more pragmatic and effective solution - simply because there are less people you&#x27;d need to convince.<p>You could get the same outcome however by having the <i>shell</i> interpret the NO_COLOR variable and have it strip colors from each subprocess where it is set.<p>Also, I believe, most programs automatically disable colors when they detect that STDOUT does not point to a terminal. So couldn&#x27;t you have the same effect by simply appending &quot;| cat&quot; to your command?
throwaway984393about 3 years ago
I wrote a shell script some time back that stripped ansi color from piped output. Haven&#x27;t needed it since, but can&#x27;t be hard to make again. So probably we don&#x27;t need this kind of quasi-standard.<p>(what&#x27;s up with all the non-IETF &quot;standards&quot; all over HN and GitHub? there is an open standards process for technology, people. is the problem that us old folks never taught the youngsters how to make them?)
tomrodabout 3 years ago
&gt; While some developers and users obviously prefer seeing these colors, many users don’t.<p>This is bold. (Pun intended).<p>Colors are immensely beneficial for opt-in. I haven&#x27;t heard very many complaints about it -- why does the author assume many users don&#x27;t?
评论 #30487150 未加载
评论 #30484486 未加载
评论 #30485399 未加载
styfleabout 3 years ago
I usually need the opposite, FORCE_COLOR=1, when non-TTY is detected but I still want colors.
评论 #30486425 未加载
评论 #30484500 未加载
ziml77about 3 years ago
I think it&#x27;s reasonable to want an easy way to disable colored output, but I don&#x27;t get why TERM doesn&#x27;t work. Unless the request here is not for no colors but instead for fewer colors.<p>But if it&#x27;s to disable all colors in applications, then I believe changing TERM should work. And if you run something that you want colored you can override TERM for that process.
评论 #30484969 未加载
Daubabout 3 years ago
The difference between Colour and non-Colour is more precisely expressed as the difference between chromacity and lightness. We must not forget that chromatic vision developed after lightness vision. The former developed as response to the availability of fruit. Effectively, fruit and chromatic vision co-evolved.<p>At a more experiential level, chromatic vision is an elaboration. It is not required, but in the lives of our ancestors, its presence signified the availability of a rare and pleasurable (carbohydrate intensive) experience.<p>In design, this principle carries through. Colour is a layer that lays on top of the lightness experience.
labsterabout 3 years ago
Title is incorrect. It should be NO_COLOR in all caps, like the environment variable.
评论 #30501826 未加载
atommclainabout 3 years ago
Conversely if you want to add color to a command, I have found Generic Colorizer to be useful: <a href="https:&#x2F;&#x2F;github.com&#x2F;garabik&#x2F;grc" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;garabik&#x2F;grc</a>
tentacleunoabout 3 years ago
This is the type of thing that should be supported in higher-level libraries like Chalk[0] (maybe it is?). We all know that Joe Bloggs&#x27; CLI isn&#x27;t going to be checking for NO_COLOR.<p>[0]: <a href="https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;chalk" rel="nofollow">https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;chalk</a>
评论 #30486295 未加载
jacheeabout 3 years ago
If something doesn’t have an option to disable color, I simply pipe its output through `cat`.<p>This is also handy for `git` commands that insist on showing a pager for fewer than a full screen worth of lines of output.
vbezhenarabout 3 years ago
I started to avoid tools dumping excessive color output, especially with emoji. This is ridiculous and extremely untasteful. Good tool must produce zero output.
maskalerabout 3 years ago
I usually handle this inside code. Colour output operators make loss difficult to read. An associated commit and message is a sign to developers that the software runs in environments without colour consoles. Finding a way to shoehorn an environment variable into a build pipeline feels like an antipattern.
drewg123about 3 years ago
What drives me <i>insane</i> is the UEFI shell using dark blue text for some things. That&#x27;s impossible to read with a black background. The last place I want to squint and guess at what something says is when I&#x27;m applying a firmware update via a uefi tool, or un-foobaring a bootloader..
dspillettabout 3 years ago
Submitted a few times in recent year. <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=21171274" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=21171274</a> is the only one I can see, after a very cursory search, that got any discussion going at all.
radford-nealabout 3 years ago
Great idea!<p>For those wondering why anyone might not like their oh so beautiful colours...<p>I like to set the background colour of the terminal to light green, and the text to black. It&#x27;s much more relaxing. Coloured output is often illegible with this setup. Plus the colours are silly anyway...
评论 #30485225 未加载
quickthrower2about 3 years ago
Also have NO_EMOJI, NO_UNASCIIS, NO_ANIMATION, NO_CLEARING_SCREEN, NO_ADS …
评论 #30486397 未加载
systemvoltageabout 3 years ago
Unrelated but is there a standard that keeps my ~&#x2F; home directory clean? I don&#x27;t want billion apps to write ~&#x2F;.foo_software_config to my home dir. It is a complete mess.
评论 #30484232 未加载
评论 #30484186 未加载
评论 #30484221 未加载
Flenserabout 3 years ago
I just use a bash alias for striping colors:<p><pre><code> alias stripcolors=&#x27; sed -r &quot;s&#x2F;\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]&#x2F;&#x2F;g&quot;&#x27;</code></pre>
scandoxabout 3 years ago
How generally are people dealing with these coloured logs when ingesting them into a centralized logging system? Is there much overhead in stripping these sort of things out.
评论 #30484138 未加载
评论 #30483942 未加载
评论 #30483962 未加载
评论 #30484677 未加载
blindmuteabout 3 years ago
&gt;I want to use weird terminal themes that don&#x27;t visually work well with most programs<p>&gt;therefore every single program must modify itself to accommodate me<p>Uhhh, nope?
transfireabout 3 years ago
Would a good terminal program support ANSI color mapping? Then you can change the mapping as desired — kind of like style-sheets for the shell.
nunezabout 3 years ago
Didn’t even know that NO_COLOR was a thing. Thanks!
sharperguyabout 3 years ago
This article reminds me a bit too much of <a href="https:&#x2F;&#x2F;xkcd.com&#x2F;927&#x2F;" rel="nofollow">https:&#x2F;&#x2F;xkcd.com&#x2F;927&#x2F;</a><p>Unless every program individually decides to implement NO_COLOR, this just adds yet another way that a program MIGHT allow you to disable color. Even if 90% of them implement it, it could just lead to issues whenever you unexpectedly run into a program in the remaining 10%.
评论 #30527409 未加载
anthkabout 3 years ago
This is good except for slash-em (too many mons with same letters).
TedShillerabout 3 years ago
Part of the reason I avoid npm
svilen_dobrevabout 3 years ago
in the last 20~ years, i see more and more programmers not being able to read (source) code if it is not colored somehow. Or to navigate without a mouse.<p>it&#x27;s like you are on a journey, and your vehicle breaks in middle, and you do not continue by feet.. because you don&#x27;t know you can walk.
评论 #30487368 未加载
dathinababout 3 years ago
&gt; many users don’t.<p>I doubt the &quot;many&quot; parts.<p>It sooo much more readable if your program outputs a lot of data.<p>And any (proper) implementation automatically switches the escape codes of if piping to another program instead of terminal so it rarely causes problems.<p>I&#x27;m sure there are still some people which do not like it, and there are some libraries which mess up colors without doubt.<p>So I&#x27;m fully in support of NO_COLOR as a &quot;de-facto&quot; standard.