cli: honor NO_COLOR environment variable to prevent automatic ASCII colors

See-also: https://no-color.org/
This commit is contained in:
Thomas Haller 2019-10-07 17:42:17 +02:00
parent d0db41c1d4
commit 597e4b2d1e
2 changed files with 9 additions and 0 deletions

View file

@ -456,6 +456,12 @@ check_colors (NmcColorOption color_option,
return FALSE;
}
if ( color_option == NMC_USE_COLOR_AUTO
&& g_getenv ("NO_COLOR")) {
/* https://no-color.org/ */
return FALSE;
}
term = g_getenv ("TERM");
if (color_option == NMC_USE_COLOR_AUTO) {

View file

@ -129,6 +129,9 @@
<citerefentry><refentrytitle>terminal-colors.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
Please refer to the <link linkend='colors' endterm='colors.title' /> section for a
list of color names supported by <command>nmcli</command>.</para>
<para>If the environment variable <literal>NO_COLOR</literal> is set (to any value),
then coloring is disabled with mode "auto". Explicitly enabling coloring overrides
the environment variable.</para>
</listitem>
</varlistentry>