Text update

This commit is contained in:
Nathaniel Landau
2015-05-26 13:44:30 -04:00
parent b1b94ab375
commit 74a447c331
2 changed files with 10 additions and 235 deletions

View File

@@ -5,24 +5,23 @@ This is the centralized repository of all the shell scripts which I use for a nu
## What's here
* **etc/** - Many of my scripts and shared functions call for configuration files. These configs are saved here. More information is in the folder's `README`.
* **lib/** - My shared scripting libraries that are used throughout my other scripts. More information is in the folder's `README`.
* **macControl/** - A collection of Scripts used by Mac applications. For example: Allow [ControlPlane][8] to run a key command.
* **setupScripts/** - This directory contains my scripts that configure new computers from scratch. Detailed information is in the folder's `README`.These scripts perform such tasks as:
* **etc/** - Many of my scripts and shared functions call for configuration files. These configs are saved here.
* **lib/** - Shared functions and libraries that are used throughout the scripts.
* **setupScripts/** - Scripts that configure new Mac computers from scratch. These scripts perform such tasks as:
* Insalling [Homebrew][1] & associated packages
* Installing mac applications using [Homebrew Cask][2]
* Configuring OSX
* Configuring OSX to my liking
* Syncing user preferences and files using [Mackup][3]
* Installing [RVM][4] and associated Gems
* Pushing a new SSH key to Github
* **syncScripts/** - I use [RSYNC][5] and [Unison][6] all the time to sync various computers, drives, and servers. More information is in the folder's `README`.
* **syncScripts/** - Scripts which use [RSYNC][5] and [Unison][6] to keep different directories and computers in sync.
## Usage
Each of the directories has its own README file which describes in more depth how to use the script(s) contained within. Most of the scripts here won't work without the scripting utilities in `lib/`.
Each of the directories has its own `README` describing in more depth how to use the files contained within. Most of the scripts here won't work without the scripting utilities in `lib/`.
## Versioning
This project implements the Semantic Versioning guidelines.
This project implements the [Semantic Versioning][7] guidelines.
Releases will be numbered with the following format:
@@ -36,6 +35,9 @@ And constructed with the following guidelines:
For more information on SemVer, please visit [SemVer][7].
## A Note on Code Reuse
The scripts herein were created by me over many years without ever having the intention to make them public. As a novice programmer, I have Googled, GitHubbed, and StackExchanged a path to solve my own scripting needs. Quite often I would lift a function whole-cloth from a GitHub repo and not keep track of it's original location. I have done my best within the scripts to recreate my footsteps and give credit to the original creators of the code when possible. Unfortunately, I fear that I missed as many as I found. My goal of making these scripts public is not to take credit for the wonderful code written by others.
[1]: http://brew.sh
[2]: http://caskroom.io
[3]: https://github.com/lra/mackup

View File

@@ -1,227 +0,0 @@
#!/usr/bin/env bash
# ##################################################
# My Generic BASH script template
#
version="1.0.0" # Sets version variable for this script
#
scriptTemplateVersion="1.1.0" # Version of scriptTemplate.sh that this script is based on
# v.1.1.0 - Added 'debug' option
#
# This script sends the key command 'command+control+option+e' via AppleScript.
# It is used to invoke a particular window configuration via Moom.
#
# For logging levels use the following functions:
# - header: Prints a script header
# - input: Ask for user input
# - success: Print script success
# - info: Print information to the user
# - notice: Notify the user of something
# - warning: Warn the user of something
# - error: Print a non-fatal error
# - die: A fatal error. Will exit the script
# - debug: Debug information
# - verbose: Debug info only printed when 'verbose' flag is set to 'true'.
#
# HISTORY:
#
# * 2015-02-09 - v1.0.0 - First Creation
#
# ##################################################
# Source Scripting Utilities
# -----------------------------------
# If these can't be found, update the path to the file
# -----------------------------------
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [ -f "${SCRIPTDIR}/../lib/utils.sh" ]; then
source "${SCRIPTDIR}/../lib/utils.sh"
else
echo "Please find the file util.sh and add a reference to it in this script. Exiting."
exit 1
fi
# trapCleanup Function
# -----------------------------------
# Any actions that should be taken if the script is prematurely
# exited. Always call this function at the top of your script.
# -----------------------------------
function trapCleanup() {
echo ""
if is_dir "${tmpDir}"; then
rm -r "${tmpDir}"
fi
die "Exit trapped." # Edit this if you like.
}
# Set Flags
# -----------------------------------
# Flags which can be overridden by user input.
# Default values are below
# -----------------------------------
quiet=0
printLog=0
verbose=0
force=0
strict=0
debug=0
# Set Local Variables
# -----------------------------------
# A set of variables used by many scripts
# -----------------------------------
# Set Script name and location variables
scriptName=`basename ${0}` # Full name
scriptBasename="$(basename ${scriptName} .sh)" # Strips '.sh' from name
scriptPath="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Set time stamp
now=$(date +"%m-%d-%Y %r")
# Set hostname
thisHost=$(hostname)
# Create temp directory with three random numbers and the process ID
# in the name. This directory is removed automatically at exit.
tmpDir="/tmp/${scriptName}.$RANDOM.$RANDOM.$RANDOM.$$"
(umask 077 && mkdir "${tmpDir}") || {
die "Could not create temporary directory! Exiting."
}
# Logging
# -----------------------------------
# Log is only used when the '-l' flag is set.
#
# To never save a logfile change variable to '/dev/null'
# Save to Desktop use: $HOME/Desktop/${scriptBasename}.log
# Save to standard user log location use: $HOME/Library/Logs/${scriptBasename}.log
# -----------------------------------
logFile="/dev/null"
function mainScript() {
############## Begin Script Here ###################
osascript -e 'tell application "System Events" to keystroke "e" using command down & option down & control down'
############## End Script Here ###################
}
############## Begin Options and Usage ###################
# Print usage
usage() {
echo -n "${scriptName} [OPTION]... [FILE]...
This script sends the key command 'command+control+option+e' via AppleScript.
It is used to invoke a particular window configuration via Moom.
Options:
-d, --debug Runs script in BASH debug mode (set -x)
-h, --help Display this help and exit
--version Output version information and exit
"
}
# Iterate over options breaking -ab into -a -b when needed and --foo=bar into
# --foo bar
optstring=h
unset options
while (($#)); do
case $1 in
# If option is of type -ab
-[!-]?*)
# Loop over each character starting with the second
for ((i=1; i < ${#1}; i++)); do
c=${1:i:1}
# Add current char to options
options+=("-$c")
# If option takes a required argument, and it's not the last char make
# the rest of the string its argument
if [[ $optstring = *"$c:"* && ${1:i+1} ]]; then
options+=("${1:i+1}")
break
fi
done
;;
# If option is of type --foo=bar
--?*=*) options+=("${1%%=*}" "${1#*=}") ;;
# add --endopts for --
--) options+=(--endopts) ;;
# Otherwise, nothing special
*) options+=("$1") ;;
esac
shift
done
set -- "${options[@]}"
unset options
# Print help if no arguments were passed.
# Uncomment to force arguments when invoking the script
# [[ $# -eq 0 ]] && set -- "--help"
# Read the options and set stuff
while [[ $1 = -?* ]]; do
case $1 in
-h|--help) usage >&2; safeExit ;;
--version) echo "$(basename $0) $version"; safeExit ;;
-u|--username) shift; username=$1 ;;
-p|--password) shift; password=$1 ;;
-v|--verbose) verbose=1 ;;
-l|--log) printLog=1 ;;
-q|--quiet) quiet=1 ;;
-s|--strict) strict=1;;
-d|--debug) debug=1;;
-f|--force) force=1 ;;
--endopts) shift; break ;;
*) die "invalid option: '$1'." ;;
esac
shift
done
############## End Options and Usage ###################
# ############# ############# #############
# ## TIME TO RUN THE SCRIPT ##
# ## ##
# ## You shouldn't need to edit anything ##
# ## beneath this line ##
# ## ##
# ############# ############# #############
# Trap bad exits with your cleanup function
trap trapCleanup EXIT INT TERM
# Exit on error. Append '||true' when you run the script if you expect an error.
set -o errexit
# Run in debug mode, if set
if [ "${debug}" == "1" ]; then
set -x
fi
# Exit on empty variable
if [ "${strict}" == "1" ]; then
set -o nounset
fi
# Bash will remember & return the highest exitcode in a chain of pipes.
# This way you can catch the error in case mysqldump fails in `mysqldump |gzip`.
set -o pipefail
mainScript # Run your script
safeExit # Exit cleanly