Repository: pre-commit/pre-commit

Issue:
Globally disable color?
I cannot find the way to globally disable color in the pre-commit output. Setting only the background color to green and not changing the foreground color does not work for my terminal with the following settings in the Xt resources (as set in the `${HOME}/.Xresources` file):

````properties
Rxvt.background: black
Rxvt.foreground: deepSkyBlue
````

Is there a way? It would be great to respect https://no-color.org/ environment variable. And, while we are here, maybe understand the following git config setting:

````ini
[color]
        ui = never
````


Discussion:

Patch:
diff --git a/pre_commit/color.py b/pre_commit/color.py
index c785e2c..2ede410 100644
--- a/pre_commit/color.py
+++ b/pre_commit/color.py
@@ -48,6 +48,9 @@ def use_color(setting):
     if setting not in COLOR_CHOICES:
         raise InvalidColorSetting(setting)
 
+    if os.environ.get('NO_COLOR'):
+        return False
+
     return (
         setting == 'always' or
         (setting == 'auto' and sys.stdout.isatty() and terminal_supports_color)


Test patch:
diff --git a/tests/color_test.py b/tests/color_test.py
index 6e11765..4ba3f32 100644
--- a/tests/color_test.py
+++ b/tests/color_test.py
@@ -1,5 +1,6 @@
 from __future__ import unicode_literals
 
+import os
 import sys
 
 import mock
@@ -50,3 +51,18 @@ def test_use_color_tty_without_color_support():
 def test_use_color_raises_if_given_shenanigans():
     with pytest.raises(InvalidColorSetting):
         use_color('herpaderp')
+
+
+def test_no_color_env_unset():
+    with mock.patch.dict(os.environ, clear=True):
+        assert use_color('always') is True
+
+
+def test_no_color_env_empty():
+    with mock.patch.dict(os.environ, NO_COLOR=''):
+        assert use_color('always') is True
+
+
+def test_no_color_env_non_empty():
+    with mock.patch.dict(os.environ, NO_COLOR=' '):
+        assert use_color('always') is False