Skip to content

Instantly share code, notes, and snippets.

@alexmacarthur
Last active November 21, 2020 02:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexmacarthur/8449f7e979be81dc9aadc9445037cff4 to your computer and use it in GitHub Desktop.
Save alexmacarthur/8449f7e979be81dc9aadc9445037cff4 to your computer and use it in GitHub Desktop.
A ZSH function for generating a super-basic HTML playground with a running development server and JS file.
# Usage:
# `playground project-name`
#
# This command will create a directory containing an HTML file, a hooked-up JS file, and turn on a development server.
function playground {
mkdir $1 && cd $1
npm init --yes
echo "<!DOCTYPE html>
<html>
<head>
<style></style>
</head>
<body>
<h1>Welcome to your playground.</h1>
<script src=\"./script.js\"></script>
</body>
</html>
" > ./index.html
echo "console.log('Hi!');" > ./script.js
echo "node_modules" > ./.gitignore
git init
git add .
git commit -m "Initial commit."
npx snowpack dev
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment