diff --git a/src/tldr_man/main.py b/src/tldr_man/main.py index 06dae85..8bbf7d3 100755 --- a/src/tldr_man/main.py +++ b/src/tldr_man/main.py @@ -27,7 +27,7 @@ from pathlib import Path from contextlib import suppress -from os import remove +from os import remove, getenv from functools import wraps import click @@ -128,7 +128,11 @@ def subcommand_manpath(locales, page_sections): print(':'.join(unique(str(man_dir.parent) for man_dir in pages.get_dir_search_order(locales, page_sections)))) -@command(cls=HelpColorsCommand, help_headers_color='yellow', help_options_color='green', no_args_is_help=True) +@command(cls=HelpColorsCommand, + help_headers_color='yellow', + help_options_color='green', + context_settings={'color': False if getenv('TLDR_MAN_NO_COLOR') or getenv('NO_COLOR') else None}, + no_args_is_help=True) @argument('page', nargs=-1, required=True, shell_complete=page_shell_complete) @option('-p', '--platform', metavar='PLATFORM', diff --git a/tldr-man.1 b/tldr-man.1 index d274645..da3178e 100644 --- a/tldr-man.1 +++ b/tldr-man.1 @@ -159,6 +159,9 @@ The location of the page cache directory. This directory is created by the command and is accessed by other commands. If this variable is not set or is not an absolute path, this defaults back to the value of .BR $XDG_CACHE_HOME/tldr-man . +.TP +.BR TLDR_MAN_NO_COLOR ", " NO_COLOR +When present and not an empty string (regardless of its value), prevents the usage of ANSI color. .SH "FILES" .TP .BR $XDG_CACHE_HOME/tldr_man @@ -183,6 +186,10 @@ TLDR\-Pages Client Specification .UR https://standards.freedesktop.org/basedir-spec/basedir-spec-latest XDG Base Directory Specification .UE . +.PP +.UR https://no-color.org/ +NO_COLOR +.UE . .SH "EXAMPLES" .PP Display the tldr\-page for