Skip to content

Commit

Permalink
Merge pull request #12 from jhasse/no_color
Browse files Browse the repository at this point in the history
Use NO_COLOR for disabling instead of CLICOLOR=0
  • Loading branch information
jhasse authored Jun 14, 2023
2 parents 681872a + 609bc62 commit b1ad692
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ The idea is to have the environment variables `CLICOLOR` and `CLICOLOR_FORCE` (w
already used for this exact reason on some UNIX systems). When set, the following rules
should apply:

* `CLICOLOR != 0`
* `NO_COLOR` set
* Don't output ANSI color escape codes, see [no-color.org](https://no-color.org)
* `CLICOLOR_FORCE` set, but `NO_COLOR` unset
* ANSI colors should be enabled no matter what.
* none of the above environment variables are set
* ANSI colors are supported and should be used when the program isn't
piped.
* `CLICOLOR == 0`
* Don't output ANSI color escape codes.
* `CLICOLOR_FORCE != 0`
* ANSI colors should be enabled no matter what.

If you have ideas or comments please
[create a new issue on GitHub](https://github.com/jhasse/clicolors/issues/new)
Expand All @@ -39,11 +39,11 @@ like this Python code example:
import os, sys

def has_colors():
if ((os.getenv("CLICOLOR", "1") != "0" and sys.stdout.isatty()) or
os.getenv("CLICOLOR_FORCE", "0") != "0"):
return True
else:
if "NO_COLOR" in os.environ:
return False
if "CLICOLOR_FORCE" in os.environ:
return True
return sys.stdout.isatty()
{% endhighlight %}

## Supported Colors
Expand Down

0 comments on commit b1ad692

Please sign in to comment.