Skip to content

Instantly share code, notes, and snippets.

@nbomberger
Forked from Gen2ly/template-basic
Created May 4, 2013 21:58
Show Gist options
  • Save nbomberger/5518895 to your computer and use it in GitHub Desktop.
Save nbomberger/5518895 to your computer and use it in GitHub Desktop.
This is a Bash script template.
#!/bin/bash
# Description of script
# 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