Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dinh/27eda4c7abc82c3a12f21acde299c641 to your computer and use it in GitHub Desktop.
Save dinh/27eda4c7abc82c3a12f21acde299c641 to your computer and use it in GitHub Desktop.
Bash Script USAGE (function, message, text content) TEMPLATE ( and/or example ... ) [ >> VERSION 2.1 ]
#===============================================================================
# NAME : bash_script_usage_v2.template.sh
# VERSION : 2.1.0
# CREATED : Dec 12 23:41:26 CST 2022
# AUTHOR : Matt Daniel Brown <dev@mattbrown.email>
# WEB : gist.github.com/mattdanielbrown/f00f119358b57a20ca9db67718dfbaf3
#-------------------------------------------------------------------------------
# USAGE : Copy the `usage()` function below and paste into your bash script
# ... and then, replace the details as is appropriate for your script.
#===============================================================================
# Print usage
usage() {
echo -n "${scriptName} [OPTION]... [FILE]...
NAME
================================================================================
The Full Name
• Expanded ('Friendly') Name Of The Script/App/Project
• SOURCE FILE ('true_executable_filename' | 'source_script_filename.sh')
• EXEC|CMD|ALIAS Name(s) (`execName` , `cmdAlias` , `cliToolName`)
DESCRIPTION
================================================================================
This is my script template.
OPTIONS
================================================================================
--------------------|---------------------------------------------------------
-f, --foo | Foo param, arg or flag opt
--------------------|---------------------------------------------------------
-b, --bar | Bar param, arg or flag opt
--------------------|---------------------------------------------------------
-a, --automate | Skip all user interaction, assuming default vaules
--------------------|---------------------------------------------------------
-q, --quiet | Quiet (no output)
--------------------|---------------------------------------------------------
-l, --log | Print log to file
--------------------|---------------------------------------------------------
-s, --strict | Exit script with null variables. i.e 'set -o nounset'
--------------------|---------------------------------------------------------
-V, --verbose | Output more information. (Items echoed to 'verbose')
--------------------|---------------------------------------------------------
-d, --debug | Runs script in BASH debug mode (set -x)
--------------------|---------------------------------------------------------
-h, --help | Display this help and exit
--------------------|---------------------------------------------------------
-v --version | Output version information and exit
--------------------|---------------------------------------------------------
================================================================================
"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment