Skip to content

Instantly share code, notes, and snippets.

@crittelmeyer
Created May 17, 2014 04:14
Show Gist options
  • Save crittelmeyer/0f12305252888ca87f2f to your computer and use it in GitHub Desktop.
Save crittelmeyer/0f12305252888ca87f2f to your computer and use it in GitHub Desktop.
A bash script to quickly create new bash scripts. It's scriptception.
#!/bin/bash -e
filename=$1
script_root=/usr/bin
editor=vi
createScriptIfItDoesntExist() {
if [ ! -f $1 ]; then
touch $1
chmod +x $1
echo "#!/bin/bash -e" >> $1
echo "" >> $1
fi
}
edit() {
createScriptIfItDoesntExist $1
$editor $1
}
script=$script_root/$filename
edit $script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment