Skip to content

Instantly share code, notes, and snippets.

@alessandro-fazzi
Created July 16, 2012 14:30
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alessandro-fazzi/3123047 to your computer and use it in GitHub Desktop.
Save alessandro-fazzi/3123047 to your computer and use it in GitHub Desktop.
colorize bash script's user interactive messages. These are helper functions for scripts
# Text color variables
txtred=$(tput setaf 1) #Red
txtgre=$(tput setaf 2) # Green
txtyel=$(tput setaf 3) # Yellow
txtblu=$(tput setaf 4) # Blue
txtbol=$(tput bold) # Bold
txtres=$(tput sgr0) # Reset
# Helper feedback functions
function info() {
echo "${txtbol} * ${1}${txtres}"
}
function success() {
echo "${txtbol}${txtgre} ** ${1}${txtres}"
}
function warning() {
echo "${txtbol}${txtyel} *** ${1}${txtres}"
}
function error() {
echo "${txtbol}${txtred} **** ${1}${txtres}"
}
function question() {
echo -n "${txtbol}${txtblu} ? ${1}?${txtres} "
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment