Skip to content

Instantly share code, notes, and snippets.

@sempervent
Last active October 12, 2021 23:45
Show Gist options
  • Save sempervent/4d94593e0d56f8fc1b43f92b9983d61f to your computer and use it in GitHub Desktop.
Save sempervent/4d94593e0d56f8fc1b43f92b9983d61f to your computer and use it in GitHub Desktop.

Revisions

  1. sempervent revised this gist Oct 11, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion bash_skeleton.sh
    Original file line number Diff line number Diff line change
    @@ -29,7 +29,7 @@ die() { # {{{2
    warn() { # {{{2
    echo -e "\\e[33mWARNING:\\e[39m $1"
    } # 2}}}
    inf() { # {{{2
    info() { # {{{2
    echo -e "\\e[32mINFO:\\e[39m $1"
    } # 2}}}
    show_help() { # {{{2
  2. sempervent revised this gist Oct 11, 2021. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion bash_skeleton.sh
    Original file line number Diff line number Diff line change
    @@ -28,7 +28,10 @@ die() { # {{{2
    } # 2}}}
    warn() { # {{{2
    echo -e "\\e[33mWARNING:\\e[39m $1"
    } # 2}}}
    } # 2}}}
    inf() { # {{{2
    echo -e "\\e[32mINFO:\\e[39m $1"
    } # 2}}}
    show_help() { # {{{2
    grep '^#/' "${BASH_SOURCE[0]}" | cut -c4- || \
    die "Failed to display usage information"
  3. sempervent revised this gist Feb 6, 2020. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions bash_skeleton.sh
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    #!/usr/bin/env bash
    # ex: set fdm=marker
    # usage {{{1
    #/ Usage:
    #/ -h|-?|--help)
  4. sempervent revised this gist Feb 6, 2020. 1 changed file with 36 additions and 27 deletions.
    63 changes: 36 additions & 27 deletions bash_skeleton.sh
    Original file line number Diff line number Diff line change
    @@ -1,46 +1,55 @@
    #!/usr/bin/env bash
    # usage {{{1 ------------------------------------------------------------------
    # usage {{{1
    #/ Usage:
    #/ -h|-?|--help)
    #/ show this help and exit
    #/
    # 1}}} ------------------------------------------------------------------------
    # environment {{{1 ------------------------------------------------------------
    # 1}}}
    # environment {{{1
    DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
    # 1}}} ------------------------------------------------------------------------
    # functions {{{1 --------------------------------------------------------------
    banner() { # {{{2 -------------------------------------------------------------
    echo -e "\\e[31m Some Project Banner\\e[39m"
    } # 2}}} ----------------------------------------------------------------------
    die() { # {{{2 ----------------------------------------------------------------
    PROJECT=${PROJECT:-"Some Project Name in $DIR"}
    # 1}}}
    # functions {{{1
    banner() { # {{{2
    # make a static banner with embeded color codes
    # BANNER=$(cat <<EOF\n EOF;
    # for a simple banner use
    # BANNER="The \n$PROJECT\n\t script"
    # or have a little funn
    # BANNER=$(figlet "$PROJECT" | cowsay)
    # or do some coloring
    BANNER="\\e[32$PROJECT\\e[39m"
    echo -e "$BANNER"
    } # 2}}}
    die() { # {{{2
    echo -e "\\e[31mFAILURE:\\e[39m $1"
    exit 1
    } # 2}}} ----------------------------------------------------------------------
    warn() { # {{{2 ---------------------------------------------------------------
    } # 2}}}
    warn() { # {{{2
    echo -e "\\e[33mWARNING:\\e[39m $1"
    } # 2}}} ----------------------------------------------------------------------
    show_help() { # {{{2 ----------------------------------------------------------
    } # 2}}}
    show_help() { # {{{2
    grep '^#/' "${BASH_SOURCE[0]}" | cut -c4- || \
    die "Failed to display usage information"
    } # 2}}} ----------------------------------------------------------------------
    # 1}}} ------------------------------------------------------------------------
    # arguments {{{1 --------------------------------------------------------------
    } # 2}}}
    # 1}}}
    # arguments {{{1
    while :; do
    case $1 in # check arguments {{{2 -------------------------------------------
    -h|-\?|--help) # help {{{3 ------------------------------------------------
    case $1 in # check arguments {{{2
    -h|-\?|--help) # help {{{3
    banner
    show_help
    exit
    ;; # 3}}} ---------------------------------------------------------------
    -?*) # unknown argument {{{3 ----------------------------------------------
    ;; # 3}}}
    -?*) # unknown argument {{{3
    warn "Unknown option (ignored): $1"
    shift
    ;; # 3}}} ---------------------------------------------------------------
    *) # default {{{3 ---------------------------------------------------------
    break # 3}}} ------------------------------------------------------------
    esac # 2}}} -----------------------------------------------------------------
    ;; # 3}}}
    *) # default {{{3
    break # 3}}}
    esac # 2}}}
    done
    # 1}}} ------------------------------------------------------------------------
    # logic {{{1 ------------------------------------------------------------------
    # 1}}}
    # logic {{{1
    banner
    # 1}}} ------------------------------------------------------------------------
    # 1}}}
  5. sempervent revised this gist Oct 3, 2019. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions bash_skeleton.sh
    Original file line number Diff line number Diff line change
    @@ -6,6 +6,7 @@
    #/
    # 1}}} ------------------------------------------------------------------------
    # environment {{{1 ------------------------------------------------------------
    DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
    # 1}}} ------------------------------------------------------------------------
    # functions {{{1 --------------------------------------------------------------
    banner() { # {{{2 -------------------------------------------------------------
  6. sempervent revised this gist Sep 23, 2019. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions bash_skeleton.sh
    Original file line number Diff line number Diff line change
    @@ -41,4 +41,5 @@ while :; do
    done
    # 1}}} ------------------------------------------------------------------------
    # logic {{{1 ------------------------------------------------------------------
    banner
    # 1}}} ------------------------------------------------------------------------
  7. sempervent revised this gist Sep 23, 2019. 1 changed file with 20 additions and 20 deletions.
    40 changes: 20 additions & 20 deletions bash_skeleton.sh
    Original file line number Diff line number Diff line change
    @@ -9,36 +9,36 @@
    # 1}}} ------------------------------------------------------------------------
    # functions {{{1 --------------------------------------------------------------
    banner() { # {{{2 -------------------------------------------------------------
    echo -e "\\e[31m Some Project Banner\\e[39m"
    echo -e "\\e[31m Some Project Banner\\e[39m"
    } # 2}}} ----------------------------------------------------------------------
    die() { # {{{2 ----------------------------------------------------------------
    echo -e "\\e[31mFAILURE:\\e[39m $1"
    exit 1
    echo -e "\\e[31mFAILURE:\\e[39m $1"
    exit 1
    } # 2}}} ----------------------------------------------------------------------
    warn() { # {{{2 ---------------------------------------------------------------
    echo -e "\\e[33mWARNING:\\e[39m $1"
    echo -e "\\e[33mWARNING:\\e[39m $1"
    } # 2}}} ----------------------------------------------------------------------
    show_help() { # {{{2 ----------------------------------------------------------
    grep '^#/' "${BASH_SOURCE[0]}" | cut -c4- || \
    die "Failed to display usage information"
    grep '^#/' "${BASH_SOURCE[0]}" | cut -c4- || \
    die "Failed to display usage information"
    } # 2}}} ----------------------------------------------------------------------
    # 1}}} ------------------------------------------------------------------------
    # arguments {{{1 --------------------------------------------------------------
    while :; do
    case $1 in # check arguments {{{2 -------------------------------------------
    -h|-\?|--help) # help {{{3 ------------------------------------------------
    banner
    show_help
    exit
    ;; # 3}}} ---------------------------------------------------------------
    -?*) # unknown argument {{{3 ----------------------------------------------
    warn "Unknown option (ignored): $1"
    shift
    ;; # 3}}} ---------------------------------------------------------------
    *) # default {{{3 ---------------------------------------------------------
    break # 3}}} ------------------------------------------------------------
    esac # 2}}} -----------------------------------------------------------------
    case $1 in # check arguments {{{2 -------------------------------------------
    -h|-\?|--help) # help {{{3 ------------------------------------------------
    banner
    show_help
    exit
    ;; # 3}}} ---------------------------------------------------------------
    -?*) # unknown argument {{{3 ----------------------------------------------
    warn "Unknown option (ignored): $1"
    shift
    ;; # 3}}} ---------------------------------------------------------------
    *) # default {{{3 ---------------------------------------------------------
    break # 3}}} ------------------------------------------------------------
    esac # 2}}} -----------------------------------------------------------------
    done
    # 1}}} ------------------------------------------------------------------------
    # logic {{{1 ------------------------------------------------------------------
    # 1}}} ------------------------------------------------------------------------
    # 1}}} ------------------------------------------------------------------------
  8. sempervent created this gist Sep 23, 2019.
    44 changes: 44 additions & 0 deletions bash_skeleton.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    #!/usr/bin/env bash
    # usage {{{1 ------------------------------------------------------------------
    #/ Usage:
    #/ -h|-?|--help)
    #/ show this help and exit
    #/
    # 1}}} ------------------------------------------------------------------------
    # environment {{{1 ------------------------------------------------------------
    # 1}}} ------------------------------------------------------------------------
    # functions {{{1 --------------------------------------------------------------
    banner() { # {{{2 -------------------------------------------------------------
    echo -e "\\e[31m Some Project Banner\\e[39m"
    } # 2}}} ----------------------------------------------------------------------
    die() { # {{{2 ----------------------------------------------------------------
    echo -e "\\e[31mFAILURE:\\e[39m $1"
    exit 1
    } # 2}}} ----------------------------------------------------------------------
    warn() { # {{{2 ---------------------------------------------------------------
    echo -e "\\e[33mWARNING:\\e[39m $1"
    } # 2}}} ----------------------------------------------------------------------
    show_help() { # {{{2 ----------------------------------------------------------
    grep '^#/' "${BASH_SOURCE[0]}" | cut -c4- || \
    die "Failed to display usage information"
    } # 2}}} ----------------------------------------------------------------------
    # 1}}} ------------------------------------------------------------------------
    # arguments {{{1 --------------------------------------------------------------
    while :; do
    case $1 in # check arguments {{{2 -------------------------------------------
    -h|-\?|--help) # help {{{3 ------------------------------------------------
    banner
    show_help
    exit
    ;; # 3}}} ---------------------------------------------------------------
    -?*) # unknown argument {{{3 ----------------------------------------------
    warn "Unknown option (ignored): $1"
    shift
    ;; # 3}}} ---------------------------------------------------------------
    *) # default {{{3 ---------------------------------------------------------
    break # 3}}} ------------------------------------------------------------
    esac # 2}}} -----------------------------------------------------------------
    done
    # 1}}} ------------------------------------------------------------------------
    # logic {{{1 ------------------------------------------------------------------
    # 1}}} ------------------------------------------------------------------------