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
1 changed files with 80 additions and 68 deletions

View File

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