Skip to content

Instantly share code, notes, and snippets.

@zygm0nt
Forked from Gen2ly/template-basic
Last active October 7, 2015 03:18
Show Gist options
  • Save zygm0nt/3097207 to your computer and use it in GitHub Desktop.
Save zygm0nt/3097207 to your computer and use it in GitHub Desktop.
bash template with colors
#!/bin/bash
# Description of script
# bash strict mode: http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -euo pipefail
IFS=$'\n\t'
# Display usage if no parameters given
if [[ -z "$@" ]]; then
echo " ${0##*/} <input> - description"
exit
fi
# Required program(s)
req_progs=(prog1 prog2)
for p in ${req_progs[@]}; do
hash "$p" 2>&- || \
{ echo >&2 " Required program \"$p\" not installed."; exit 1; }
done
# Text color variables
txtund=$(tput sgr 0 1) # Underline
txtbld=$(tput bold) # Bold
bldred=${txtbld}$(tput setaf 1) # red
bldblu=${txtbld}$(tput setaf 4) # blue
bldwht=${txtbld}$(tput setaf 7) # white
txtrst=$(tput sgr0) # Reset
info=${bldwht}*${txtrst} # Feedback
pass=${bldblu}*${txtrst}
warn=${bldred}*${txtrst}
ques=${bldblu}?${txtrst}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment