Giter Club home page Giter Club logo

add_bash_template's Introduction

Contents

  1. mksh
  2. add_bash_templates
  3. BEFORE RUNNING
  4. WHAT DOES add_bash_templates DO?
  5. USAGE

mksh

running mksh will create a file, name file, give permissions, and add a header with (name, date, type, time, copyright, ...) mksh will execute add_bash_templates, which will grep all template headers to give you a menu so you can add the templates you wish to use.

the value of this is you can quickly add code templates you are aware you will need, like "for loops", "main function", "nested if statements, nested for loops, nested functions" then fill the templates with your code. it simply speeds up the process of organizing and writing bash files, also by filling the header with nessesary info for you, automating the process, saving you time.

EXAMPLE FILE:

#!/usr/bin/env bash

    ################################################
    # Name: new_sh_file          Date: 07/06/21
    # Time: 01:22                Type: Bash
    # Copyright: none
    # Goal:
    #
    ################################################

# section_variables

########## header files ###########
#source ./<path/somefilename>
#source ./<path/somefilename> 

########### variables #############
a1=$1; a2=$2; a3=$3; a4=$4

#_ section_functions

########### functions #############

#_ missing_requirements_exit

# error function 
function error(){
     echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $*" >&2
}

# didnt supply any arguments when executing script
if [[ $# -lt 0 ]]; then
    err "Missing required argument\n"
    exit 1
fi

# did not run as root
if [[ $UID == 1 ]];then 
    err "Error: you must be root to run this script, try sudo <scriptname>"
    exit 1
fi

#_ section_main

############# main ################


#_ skeleton_main_while_if
function main(){ # <arg1> <arg2>
    local input1
    local input2
    input1=$1
    input2=$2
    # infinite loop
    while :
    do
            if [[ $1 == 1 ]]; then
                    #something
            elif [[ $2 < 1 ]]; then
                    #something
            else
                    #something
            fi
    done
}

add_bash_templates

choose templates of functions, variables, loops, etc... from a bash_templates file to add to your file.sh whats great about this is the entire process is sizable. you can remeove any templates or add any custom templates to "bash_templates" file. as long as you follow the "Example:" under "BEFORE RUNNING:" if the template header in the file does not have the proper syntax it may not get picked up as an option in the "add_bash_templates" menu.

BEFORE RUNNING:

For this to work you need

  1. add_bash_templates
  2. bash_templates
  3. mksh

add your own custom templates inside <bash_templates>

Before and after each template in <bash_templates>

  1. line must start with "#_"
  2. a space
  3. the title of the template seperated by "_"

EXAMPLE "#_ basic_functions"

  note
  
  without an underscore in the name it will
  not show in list of avialable templates to choose

WHAT DOES add_bash_templates DO?:

creates a list of templates to choose from by number, the selected template is then found in the file <bash_templates> and added to your new bash file <tmp.sh>.

USAGE:

MAKING A NEW .sh FILE

Syntax

 ./mksh

ADDING TO EXISTING FILE

Syntax

 ./add_bash_template <arg1> 

Example

 ./add_bash_template file.sh

add_bash_template's People

Contributors

loganran625 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.