Skip to content

Instantly share code, notes, and snippets.

@jobywalker
Created June 8, 2013 03:01
Show Gist options
  • Select an option

  • Save jobywalker/5733821 to your computer and use it in GitHub Desktop.

Select an option

Save jobywalker/5733821 to your computer and use it in GitHub Desktop.
Standard bash script format
<snippet>
<content><![CDATA[
#!/bin/bash
#
# ${1:SCRIPT-NAME}
#
# ${2:DESCRIPTION}
#
# \$Id\$
# \$URL\$
###################################################
#
# Functions
#
function usage {
cat << EOF
usage: ${1:SCRIPT-NAME} [ -v ]
${1:SCRIPT-NAME} -h
Required:
Optional:
-v
Verbose output
Other:
-h
Print this usage text
EOF
}
function ifverbose {
if [[ -n $verbose ]]; then
printf "%b\n" "\$*"
fi
}
###################################################
#
# Defaults
#
###################################################
#
# Get Options
#
while getopts vh flag; do
case \$flag in
h)
usage
exit
;;
v)
verbose="verbose"
;;
?)
usage
exit 1
;;
esac
done
###################################################
#
# The script
#
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>bash-script</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.shell</scope>
</snippet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment