Skip to content

Commit

Permalink
chore: ignore ouput colors when TERM is dumb
Browse files Browse the repository at this point in the history
Original idea: #247 (comment)
Co-authored-by: h0adp0re <[email protected]>
  • Loading branch information
Chemaclass committed Jul 23, 2024
1 parent 27641e1 commit 4e55a55
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/colors.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,22 @@
# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters
# Credit:
# https://superuser.com/a/1119396
sgr() {
local codes=${1:-0}
function sgr() {
local codes return
codes=${1:-0}
shift

for c in "$@"; do
codes="$codes;$c"
done

echo $'\e'"[${codes}m"
return=$'\e'"[${codes}m"

if [[ $TERM == 'dumb' ]]; then
return=""
fi

echo "$return"
}

_COLOR_BOLD="$(sgr 1)"
Expand Down

0 comments on commit 4e55a55

Please sign in to comment.