Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 48 lines (38 sloc) 976 Bytes
#!/usr/bin/env bash
set -e
NAME="$1"
if [ -z "$NAME" ]; then
echo "usage: prepare.sh NAME_OF_YOUR_SUB" >&2
exit 1
fi
SUBNAME=$(echo $NAME | tr '[A-Z]' '[a-z]')
ENVNAME="$(echo $NAME | tr '[a-z-]' '[A-Z_]')_ROOT"
echo "Preparing your '$SUBNAME' sub!"
if [ "$NAME" != "sub" ]; then
rm bin/sub
mv share/sub share/$SUBNAME
for file in **/sub*; do
sed "s/sub/$SUBNAME/g;s/SUB_ROOT/$ENVNAME/g" "$file" > $(echo $file | sed "s/sub/$SUBNAME/")
rm $file
done
for file in libexec/*; do
chmod a+x $file
done
ln -s ../libexec/$SUBNAME bin/$SUBNAME
fi
rm README.md
rm prepare.sh
echo "Done! Enjoy your new sub! If you're happy with your sub, run:"
echo
echo " rm -rf .git"
echo " git init"
echo " git add ."
echo " git commit -m 'Starting off $SUBNAME'"
echo " ./bin/$SUBNAME init"
echo
echo "Made a mistake? Want to make a different sub? Run:"
echo
echo " git add ."
echo " git checkout -f"
echo
echo "Thanks for making a sub!"