mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 19:46:05 +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:
parent
ddee030dc7
commit
69e2693342
4 changed files with 15 additions and 3 deletions
|
|
@ -1,5 +1,7 @@
|
|||
# The check for terminal output and color support is heavily inspired
|
||||
# by https://unix.stackexchange.com/a/10065.
|
||||
#
|
||||
# Allow opt out by respecting the `NO_COLOR` environment variable.
|
||||
|
||||
function setupColors() {
|
||||
normalColor=""
|
||||
|
|
@ -7,8 +9,8 @@ function setupColors() {
|
|||
warnColor=""
|
||||
noteColor=""
|
||||
|
||||
# Check if stdout is a terminal.
|
||||
if [[ -t 1 ]]; then
|
||||
# Enable colors for terminals, and allow opting out.
|
||||
if [[ ! -v NO_COLOR && -t 1 ]]; then
|
||||
# See if it supports colors.
|
||||
local ncolors
|
||||
ncolors=$(tput colors)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue