forked from qrush/sub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepare.sh
executable file
·47 lines (38 loc) · 976 Bytes
/
prepare.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/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!"