diff --git a/man/nmcli.xml b/man/nmcli.xml index 1caafd3176..9bda9db0af 100644 --- a/man/nmcli.xml +++ b/man/nmcli.xml @@ -129,8 +129,9 @@ terminal-colors.d5. Please refer to the section for a list of color names supported by nmcli. - If the environment variable NO_COLOR is set (to any value), - then coloring is disabled with mode "auto". Explicitly enabling coloring overrides + If the environment variable NO_COLOR is set (to any non-empty value), + then coloring is disabled with mode "auto". If the environment variable CLICOLOR_FORCE + is set (to any non-empty value), then coloring is enabled with mode "auto". Explicitly enabling coloring overrides the environment variable. diff --git a/src/nmcli/nmcli.c b/src/nmcli/nmcli.c index 792edf6e0e..6de42faa00 100644 --- a/src/nmcli/nmcli.c +++ b/src/nmcli/nmcli.c @@ -481,7 +481,7 @@ check_colors(NmcColorOption color_option, char **out_palette_str) return FALSE; } - if (color_option == NMC_USE_COLOR_AUTO && g_getenv("NO_COLOR")) { + if (color_option == NMC_USE_COLOR_AUTO && nm_str_not_empty(g_getenv("NO_COLOR"))) { /* https://no-color.org/ */ return FALSE; } @@ -489,7 +489,9 @@ check_colors(NmcColorOption color_option, char **out_palette_str) term = g_getenv("TERM"); if (color_option == NMC_USE_COLOR_AUTO) { - if (nm_streq0(term, "dumb") || !isatty(STDOUT_FILENO)) + if (nm_str_not_empty(g_getenv("CLICOLOR_FORCE"))) { + color_option = NMC_USE_COLOR_YES; + } else if (nm_streq0(term, "dumb") || !isatty(STDOUT_FILENO)) return FALSE; }