2 ms·
It does complicated matters if you're capturing command output in logfiles or an editor. In my scripts, I just check for unset term and/or use tput to get the
by m463 6y ago
It does complicated matters if you're capturing command output in logfiles or an editor.
In my scripts, I just check for unset term and/or use tput to get the sequences (which honors TERM=dumb)
one example:
col_ok=`tput bold; tput setaf 7; tput setab 2`
col_fail=`tput bold; tput setaf 7; tput setab 1`
col_end=`tput sgr0`
echo "${col_fail} ERROR: it failed ${col_end}"
so running the script gives me colorized output (xterm-256color),
but running it like this:
TERM=dumb <script>
gives plain text