Disabling ANSI color output
no-color.org
no-color.org
Here's the workaround I use:
brew() { /usr/local/bin/brew "$@" | cat; }That's all the code does.
> … but about adopting a "standard" that someone made up by themselves.
People's imagination is where standards come from.
People make them up and get agreement from other people to implement them.
Software development is a social activity, and if someone wants to introduce new functionality, they have to convince others that it's a desirable change. Making up a "standard" is the easy part; I'd expect that convincing others to adopt it is more challenging.
Technically terminals can play the interactive role in place of “less”: ^S/^Q, scrollback and search, etc. If that were more common, programs might not be misusing color/style sequences like this (as there wouldn’t be a common “interactive pipe” use case to support).
If ANSI sequences were only color, they might be feasible; getting a clear idea on what “appropriately” means for general ANSI content in a text stream is... difficult.
[0] https://en.wikipedia.org/wiki/Cat_(Unix)#UUOC_(Useless_Use_O...
9term also does not support a lot of other terminal features. Using it I’ve noticed that there are two kinds of terminal programs:
1. Programs that uses the terminal as a GUI.
2. Programs that can be composed with other programs.
I prefer a program in category 2, since I like scripting to automate my tasks.
Worse, many programs break when you start getting fancy. If you would just stop trying to add color to your node programs, stop trying to add emojis, stop trying to control the entire terminal window, then suddenly everything would work much better. If you kick off multiple processes, you can simply console.log() instead of having to set up an RPC interface to communicate with the main process. (This actually happened.) If you stop putting emojis in your error messages, then WebStorm can highlight the stack traces automatically when you run in the debugger, enabling you to jump to the stack trace just by clicking on it. This breaks when you add emojis. (Also happened.) And if you stop adding color, then you can redirect to a file without screwing things up.
In short, stop getting fancy. :)
I similarly dislike the new trend of fancy command prompts. It’s a prompt, it should stay in the background.
I simply find terminal programs that generate colour distracting.
Yes.
> I think colors are a great way to enhance output, as it is like a third dimension to formatting.
I don't. I view them as a OOB marker that causes the coloured content to effectively jump the queue into my brain.
> having errors in red immediately can signal something bad happened.
As a specific counter-example: I'm often interested in the log output that occurred right before something bad happened, so having errors in red is exactly what I don't want.
The result is not what you'd like. You'd really like to specify an overall scheme (light on dark, or dark on light) and then hues for each character displayed.
That'd let you see green on green just fine. It wouldn't even be possible for the foreground and background to be identical, because one would be light and one would be dark.
I suppose that switching everybody over might not be as hard as I thought at first. Considering systemd, it only takes a manager at Red Hat to force a new standard. I sure would appreciate it.
I am used to a black background. Seems like the logical "default" starting point in VGA textmode. Even Linux kernel output when booting starts on a black blackground.
(I do know the colours can be adjusted in the terminal config, and many tools have options to switch to a white background. Would be nice if the defaults worked better though.)
[1] http://images.standaloneinstaller.com/images/mirc-BZEwO8ZcLm...
[2] http://amnesiac.ircii.org/screenshots/lookgood.png
`if sys.stdout.isatty(): ...`
I recognize TTY != ANSI in some cases. And sometimes you actually want control sequences captured or redirected. So this is far from perfect but it might be good enough for some.
Such a check ports across systems well and doesn't rely on a new environment variable.
Looks like this is already supported by more software; rather than an n+1 standard (https://xkcd.com/927/), why not use this one instead?
One other potential issue with this (an issue that also applies to GNU make's MAKE_TERMOUT and MAKE_TERMERR environment variables, documented at https://www.gnu.org/software/make/manual/make.html#Terminal-...): what happens if someone sets CLICOLOR_FORCE or MAKE_TERMOUT to indicate that output will (eventually) go to a terminal for output, but then some portion of the build system actually does want to redirect output to a file or pipe that won't eventually get printed to a terminal? Does that part of the build system then need to explicitly unset CLICOLOR_FORCE and MAKE_TERMOUT and any other variable the program might potentially respect, to make sure it won't include color in its output? That seems likely to produce breakage.
Consider if grep respected CLICOLOR_FORCE or MAKE_TERMOUT. What would happen if a build system set one of those, and then somewhere deep in the build system (or even in a shell script called from the build system), someone ran grep in a pipeline, along with various other text processing commands? If grep respected those environment variables, then that pipeline would break.
I do like the idea of having a standard way to tell a program "no, really, your output will wind up on the terminal, please print in color even though it doesn't look like a TTY". However, I don't think it makes sense to do so without a solution for this problem. Not showing color output is an annoyance; breaking a build by printing color escape sequences to a pipe would be far worse.
(This is also part of why programs like grep are removing environment variables like GREP_OPTIONS: they break scripts.)
Yes, it should be the responsibility of the build system to control the environment variables set during the build.
What would happen if a build system set one of those, and then somewhere deep in the build system (or even in a shell script called from the build system), someone ran grep in a pipeline
The person adding the 'grep' would need to be aware of whether the build system is using color output or not.
This is also part of why programs like grep are removing environment variables like GREP_OPTIONS: they break scripts.
This seems unfortunate; scripts could just unset GREP_OPTIONS if they care.
grep is portable, and much older than GREP_OPTIONS. A script shouldn't be expected to fix any random non-standard idiosyncrasy of the local version of grep.
It would be great if grep could figure out whether its parent process is an interactive shell or a script, but there doesn't seem to be a reliable way to do that.
programs like make could collect output using a pty rather than a pipe or temp file
This seems brilliant. The pipe mechanism is too dumb to differentiate between these cases - Unix needs a smarter pipe, and pty could be it. Maybe there could be another character in the shell for a pipe that's really a pty like '_', or a digraph like '|p'.
I think that just having the CLICOLOR option would be reasonable, for enabling or disabling color to a TTY, but CLICOLOR_FORCE is more problematic.
Yeah, I'd agree with that.
I posted this same link 2 days ago: https://news.ycombinator.com/item?id=16305172
https://hn.algolia.com/?query=dang%20deliberately%20porous&s...
As someone else said, "I like strawberries, therefore everyone likes strawberries". A quick summary of potential reasons:
- it's distracting (https://news.ycombinator.com/item?id=16323038)
- colorblindness (https://news.ycombinator.com/item?id=16322796)
- bad default color schemes (https://news.ycombinator.com/item?id=16322812)
- escape codes may break text processing (https://news.ycombinator.com/item?id=16322600)