From 67c9562826ae187f403e11ef8e248644e79384f8 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Mon, 14 Nov 2022 16:42:11 +0100 Subject: [PATCH] NO_COLOR environment as default --color Popular standard explained on: https://no-color.org/ --- barcat | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/barcat b/barcat index 62c1dbc..6ab610d 100755 --- a/barcat +++ b/barcat @@ -105,7 +105,7 @@ GetOptions(\%opt, } $opt{width} ||= $ENV{COLUMNS} || qx(tput cols) || 80 unless $opt{spark}; -$opt{color} //= -t *STDOUT; # enable on tty +$opt{color} //= $ENV{NO_COLOR} ? 0 : -t *STDOUT; # enable on tty $opt{'graph-format'} //= '-'; $opt{trim} *= $opt{width} / 100 if $opt{trimpct}; $opt{units} = [split //, ' kMGTPEZYyzafpn'.($opt{ascii} ? 'u' : 'μ').'m'] @@ -435,6 +435,8 @@ Input is always interpreted as UTF-8 and shown as is. Force colored output of values and bar markers. Defaults on if output is a tty, disabled otherwise such as when piped or redirected. +Can also be disabled by setting I<-C> +or the I environment variable. =item -f, --field=( | ) -- 2.30.0