Skip to content

Instantly share code, notes, and snippets.

@juliankrispel
Last active December 17, 2015 03:59
Show Gist options
  • Save juliankrispel/5547500 to your computer and use it in GitHub Desktop.
Save juliankrispel/5547500 to your computer and use it in GitHub Desktop.
Bash scripting

#Steps to create shell script

  1. Create folder for your shell scripts like ~/.bin
  2. Create script file ~/.bin/script
  3. Chmod it chmod +x ~/.bin/script

##Conditionals:

if [ $1 ]
then
    # do stuff 
else
    # show help
fi

##Functions

function help () {
    echo "jazz - A simple script that makes using the Jasmine testing framework in a standalone project a little simpler."
    echo "
    echo "    jazz init                  - include jasmine in the project";
    echo "    jazz create FunctionName   - creates ./src/FunctionName.js ./spec/FunctionNameSpec.js";
    echo "    jazz run                   - runs tests in browser";
}

##Case

case "$1" in
 init)
  
 ;;
 create)
  
 ;;
 run)
  
 ;;
 *)
    help
 ;;
esac

##Arrays

//Appending to arrays without reference:

ARRAY=()
ARRAY+=('foo')
ARRAY+=('bar')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment