Skip to content

Instantly share code, notes, and snippets.

@todd-dsm
Last active April 25, 2021 07:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save todd-dsm/7c6303e2f039bbe8046cbeb613e7b1a8 to your computer and use it in GitHub Desktop.
Save todd-dsm/7c6303e2f039bbe8046cbeb613e7b1a8 to your computer and use it in GitHub Desktop.
colorized output with tput
#------------------------------------------------------------------------------
# FUNCTION: First, nobody should do this. Second, it totally works. This is a
# library to print messages in a consistent format.
# AUTHORS: todd-dsm
#------------------------------------------------------------------------------
###----------------------------------------------------------------------------
### VARIABLES
###----------------------------------------------------------------------------
valDATE="$(date +%F\ %r)"
myFileName="$(basename $0)"
bold=$(tput bold)
green=$(tput setaf 2)
red=$(tput setaf 1)
clear=$(tput sgr0)
#------------------------------------------------------------------------------
# Set the variant colors for specific outputs; %s is your string
#------------------------------------------------------------------------------
# Print Requirement
printReq() {
printf '\n%s\n' "$bold$1$clear"
}
# Print 1 line of info
print1Line() {
printf '%s\n\n' "$1"
}
# Print Info
printInfo() {
printf '%s\n' " $1"
}
# Print final Success status
printSStat() {
printf '%s\n\n' "$green $1$clear"
}
# Print final Failure status
printFStat() {
printf '%s\n\n' "$red $1$clear"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment