Stripping tput off when terminal is not xterm

This commit is contained in:
DarkFeather 2023-01-25 22:44:05 -06:00
parent 16c864e161
commit 8435ff442b
Signed by: DarkFeather
GPG Key ID: 1CC1E3F4ED06F296

View File

@ -6,13 +6,25 @@ pullcmd='wget --timeout=5 -q -O -'
## Visual Functions ## ## Visual Functions ##
# These function creates a visual indicator that a step has happened. # These function creates a visual indicator that a step has happened.
function header () { function header () {
if [[ "$TERM" =~ xterm* ]]; then
tput setaf 1; tput bold; echo $@; tput sgr0; return tput setaf 1; tput bold; echo $@; tput sgr0; return
else
echo $@;
fi
} }
function errorheader () { function errorheader () {
if [[ "$TERM" =~ xterm* ]]; then
tput setaf 1 1>&2; tput bold 1>&2; echo "ERROR:" $@ 1>&2; tput sgr0 1>&2; return tput setaf 1 1>&2; tput bold 1>&2; echo "ERROR:" $@ 1>&2; tput sgr0 1>&2; return
else
echo $@;
fi
} }
function infoheader() { function infoheader() {
if [[ "$TERM" =~ xterm* ]]; then
tput setaf 3; tput bold; echo $@; tput sgr0; return tput setaf 3; tput bold; echo $@; tput sgr0; return
else
echo $@;
fi
} }
function colorstrip() { function colorstrip() {
perl -e 'use strict; use warnings; while(<>) { s/\e\[[\d;]*m//g; print; }' perl -e 'use strict; use warnings; while(<>) { s/\e\[[\d;]*m//g; print; }'