In a shell script, how can I test whether or not the terminal supports 24-bit or true color?

Related: This question is about printing a 24-bit / truecolor test pattern for eyeball verification


This source says to check if $COLORTERM contains 24bit or truecolor.


[ "$COLORTERM" = truecolor ] || [ "$COLORTERM" = 24bit ]

bash / zsh:

[[ $COLORTERM =~ ^(truecolor|24bit)$ ]]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.