Last active
April 25, 2021 07:09
-
-
Save todd-dsm/7c6303e2f039bbe8046cbeb613e7b1a8 to your computer and use it in GitHub Desktop.
colorized output 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
#------------------------------------------------------------------------------ | |
# 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