Skip to content

Commit

Permalink
Improve color detection
Browse files Browse the repository at this point in the history
  • Loading branch information
evhub committed May 13, 2024
1 parent b2c4e5f commit 0196d71
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion coconut/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,13 @@ def logging(self):
def should_use_color(file=None):
"""Determine if colors should be used for the given file object."""
use_color = get_bool_env_var(use_color_env_var, default=None)
if use_color is None:
use_color = get_bool_env_var("PYTHON_COLORS", default=None)
if use_color is not None:
return use_color
if get_bool_env_var("CLICOLOR_FORCE") or get_bool_env_var("FORCE_COLOR"):
if get_bool_env_var("NO_COLOR"):
return False
if get_bool_env_var("FORCE_COLOR") or get_bool_env_var("CLICOLOR_FORCE"):
return True
return file is not None and isatty(file)

Expand Down

0 comments on commit 0196d71

Please sign in to comment.