To download and then use a script
wget https://raw/gist/url/script.sh
chmod +x script.sh
to execute directly
bash <(curl -s http://raw/gist/url/script.sh) <args>
#!/usr/bin/env bash | |
# Create an empty theme at the specified location | |
# e.g. ./mktheme.sh mytheme | |
# THIS WILL OVERWRITE ANY EXISTING FILES! | |
# You have been warned - it is not a clever script | |
function dirs { | |
cat <<EOF | |
assets/css | |
assets/fonts | |
assets/images | |
assets/js | |
partials | |
EOF | |
} | |
function files { | |
cat <<EOF | |
assets/css/screen.css | |
default.hbs <h1>Hello World</h1> | |
post.hbs {{!< default}} | |
index.hbs {{!< default}} | |
package.json | |
EOF | |
} | |
function package_json_for { | |
theme=$1 | |
cat<<EOF | |
{ | |
"name" : "$theme", | |
"version": "0.0.1" | |
} | |
EOF | |
} | |
THEME=$1 | |
[[ -z $THEME ]] && exit 1 | |
echo "Making new theme at $PWD/$THEME" | |
dirs | sed "s@^@$THEME/@" | while read dir ; do | |
mkdir -p $dir && echo "Added dir $dir" | |
[[ $? -ne 0 ]] && exit 1 | |
done | |
files | sed "s@^@$THEME/@" | while read file content; do | |
touch $file | |
[[ $? -ne 0 ]] && exit 1 | |
[[ ! -z $content ]] && echo $content > $file | |
echo "Added file $file" | |
done | |
echo "Added package.json" | |
package_json_for $THEME | tee $THEME/package.json |