Last active
January 21, 2022 02:32
-
-
Save peterrus/f3dd5142720f6c80ac980e286d52cfad to your computer and use it in GitHub Desktop.
Simple status colors in Bash with tput
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Colors and fonts | |
# Only loaded on interactive terminals | |
if [ -t 0 ]; then | |
T_ERROR=$(tput setaf 7; tput setab 1) | |
T_INFO=$(tput setaf 7; tput setab 4) | |
T_WARNING=$(tput setaf 0; tput setab 3) | |
T_SUCCESS=$(tput setaf 0; tput setab 2) | |
T_BOLD=$(tput bold) | |
T_RESET=$(tput sgr0) | |
fi | |
# End colors and fonts | |
echo "${T_INFO}Informative text.${T_RESET}" | |
echo "${T_ERROR}Stuff is hitting the ${T_BOLD}proverbial${T_RESET}${T_ERROR} fan!${T_RESET}" | |
echo "${T_WARNING}This is a warning!${T_RESET}" | |
echo "${T_SUCCESS}Everything is alright...${T_RESET}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment