Skip to content

Instantly share code, notes, and snippets.

@forestbaker
Forked from crittelmeyer/cmd
Created October 11, 2015 21:10
Show Gist options
  • Save forestbaker/ddc2a2fdd35a0bb2255f to your computer and use it in GitHub Desktop.
Save forestbaker/ddc2a2fdd35a0bb2255f 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