Hullo - If I want to determine the # of colours a terminal can display I simply read the output of
tput colors
... however I cannot figure out how to determine if the terminal I'm writing to can support other formatting requests such as bold, underline, reverse-video, blink (yuck!).
I see how to set output via tput, but not determine if the capability exists before attempting.
Should I simply assume the capability exists in all terminals ?
You can use
infocmp
for this, andgrep
on the capability you are looking for. If a result is found, then the capability is supported:In order to get the names of the different capabilities check out the Linux man pages for terminfo, or this one for a tabular layout of names.