1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-27 05:29:46 +01:00

home-manager: respect NO_COLOR environment variable

This makes Home Manager respect the NO_COLOR environment variable to
disable coloring from output generated by Home Manager.

This initiative can be found more on https://no-color.org/
This commit is contained in:
Teo Ljungberg 2021-03-01 13:22:33 +01:00 committed by Robert Helgesson
parent ddee030dc7
commit 69e2693342
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
4 changed files with 15 additions and 3 deletions

View file

@ -111,6 +111,9 @@ configure.packages.*.start -> programs.neovim.plugins = [ { plugin = ...; }]
configure.customRC -> programs.neovim.extraConfig configure.customRC -> programs.neovim.extraConfig
---- ----
* Home Manager now respects the `NO_COLOR` environment variable as per
https://no-color.org/[].
[[sec-release-21.05-state-version-changes]] [[sec-release-21.05-state-version-changes]]
=== State Version Changes === State Version Changes

View file

@ -221,7 +221,7 @@ function doSwitch() {
function doListGens() { function doListGens() {
# Whether to colorize the generations output. # Whether to colorize the generations output.
local color="never" local color="never"
if [[ -t 1 ]]; then if [[ ! -v NO_COLOR && -t 1 ]]; then
color="always" color="always"
fi fi

View file

@ -1,5 +1,7 @@
# The check for terminal output and color support is heavily inspired # The check for terminal output and color support is heavily inspired
# by https://unix.stackexchange.com/a/10065. # by https://unix.stackexchange.com/a/10065.
#
# Allow opt out by respecting the `NO_COLOR` environment variable.
function setupColors() { function setupColors() {
normalColor="" normalColor=""
@ -7,8 +9,8 @@ function setupColors() {
warnColor="" warnColor=""
noteColor="" noteColor=""
# Check if stdout is a terminal. # Enable colors for terminals, and allow opting out.
if [[ -t 1 ]]; then if [[ ! -v NO_COLOR && -t 1 ]]; then
# See if it supports colors. # See if it supports colors.
local ncolors local ncolors
ncolors=$(tput colors) ncolors=$(tput colors)

View file

@ -1873,6 +1873,13 @@ in
'accounts.email.accounts.<name>.msmtp.enable' is true. 'accounts.email.accounts.<name>.msmtp.enable' is true.
''; '';
} }
{
time = "2021-03-03T22:16:05+00:00";
message = ''
Home Manager now respects the 'NO_COLOR' environment variable as per
https://no-color.org/.
'';
}
]; ];
}; };
} }