cli icon indicating copy to clipboard operation
cli copied to clipboard

Support $NO_COLOR in CLI output

Open hslatman opened this issue 2 years ago • 6 comments

It would be nice to support the $NO_COLOR environment variable, so that users with this preference (always) get plain text output. This is also helpful for piping output to other tools without having to get rid of the color escape codes.

Also see https://no-color.org/ and https://clig.dev/#output for more reasoning behind this. The issue has come up several times internally now.

It may be possible to change usage of colors with the libs we already use. Another option may be to look into https://github.com/muesli/termenv, which seems to make the CLI a lot smarter around using styles, but is probably a larger piece of work.

hslatman avatar Mar 09 '22 08:03 hslatman

If we turned off color, would that include turning off emojis too or should that be its own flag NO_EMOJI?

jdoss avatar Mar 09 '22 15:03 jdoss

I would say to turn these off with$NO_COLOR too, yes. They're in color, after all, so unless we can reliably convert them to ASCII .... 😅 And $NO_COLOR seems to be a convention; $NO_EMOJI would probably be somewhat of a surprise.

hslatman avatar Mar 09 '22 15:03 hslatman

I thought the main use case for NO_COLOR was preventing bash color escape sequences from getting spit out, in which case emoji are fine (just unicode chars) imo. But, maybe some people just hate all color too? :art:

alanchrt avatar Mar 09 '22 17:03 alanchrt

A highlight of my day to see this ref to my side project https://clig.dev!

tashian avatar Mar 09 '22 18:03 tashian

Good point, @alanchrt; I didn't think of it like that. There are people on the internet that want to disable emojis in terminal output, so supporting that sounds good to me.

I think we're using emoji in two ways: first one is adding a bit of character to the CLI and the second is more functional usage, like outputting OK/NOK statuses. A different approach may be necessary for them.

It's a great resource, @tashian! 😄

hslatman avatar Mar 10 '22 09:03 hslatman

We also will print out fingerprints as emoji these days:

https://mobile.twitter.com/smallsteplabs/status/1489669356719988736

alanchrt avatar Mar 10 '22 22:03 alanchrt