From 705c1bec93876ced4c617a41ff11a293e48968b4 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Tue, 9 May 2023 11:30:46 -1000 Subject: [PATCH] ;fix: hledger-bar: detect non-interactive output properly for ANSI --- bin/hledger-bar | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/hledger-bar b/bin/hledger-bar index c2c74c85c..5a2e5b7e8 100755 --- a/bin/hledger-bar +++ b/bin/hledger-bar @@ -75,8 +75,9 @@ poschar="+" # utils -# https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit and 24-bit colors: -if [[ $- != *i* || -v $NO_COLOR ]]; then +# https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit and 24-bit colors. +# Disable if stdout is not a terminal or NO_COLOR is defined. +if [[ ! -t 1 || -v $NO_COLOR ]]; then red='' green='' nocol=''