Here’s a one-shot bash script that scaffolds a simple VS Code web project for a digital clock timer (HTML/CSS/JS), configures a basic VS Code launch setup, initializes git, and even opens VS Code for you when it’s done.
Save this as create-clock-timer.sh, make it executable, and run it with an optional project-name argument:
bash Copy code
#!/usr/bin/env bash
# create-clock-timer.sh
# Usage: ./create-clock-timer.sh [project-name]
# Defaults to “clock-timer” if no name is given.
set -e
PROJECT=${1:-clock-timer}
echo "🚀 Creating project \"$PROJECT\"…"
# 1. Make directories
mkdir -p "$PROJECT"/{.vscode,src}
cd "$PROJECT"
# 2. Initialize git & .gitignore
git init -q
cat > .gitignore << EOF
# Node / Misc
node_modules/
dist/
.vscode/
EOF
# 3. Create HTML/CSS/JS boilerplate
cat > src/index.html << 'EOF'
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Clock Timer</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div class="clock" id="clock">00:00:00</div>
<script src="script.js"></script>
</body>
</html>
EOF
cat > src/style.css << 'EOF'
/* style.css */
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background: #282c34;
color: #61dafb;
font-family: 'Segoe UI', sans-serif;
}
.clock {
font-size: 5rem;
letter-spacing: 0.1em;
}
EOF
cat > src/script.js << 'EOF'
// script.js
function updateClock() {
const now = new Date();
const h = String(now.getHours()).padStart(2,'0');
const m = String(now.getMinutes()).padStart(2,'0');
const s = String(now.getSeconds()).padStart(2,'0');
document.getElementById('clock').textContent = `${h}:${m}:${s}`;
}
setInterval(updateClock, 1000);
updateClock();
EOF
# 4. Add VS Code debug configuration (via Chrome)
cat > .vscode/launch.json << 'EOF'
{
"version": "0.2.0",
"configurations": [
{
"type": "pwa-chrome",
"request": "launch",
"name": "Launch Clock Timer",
"file": "${workspaceFolder}/src/index.html",
"webRoot": "${workspaceFolder}/src"
}
]
}
EOF
# 5. (Optional) Add a simple npm script to serve locally
cat > package.json << 'EOF'
{
"name": "$PROJECT",
"version": "1.0.0",
"scripts": {
"start": "npx http-server src -c-1 -p 5500"
},
"devDependencies": {
"http-server": "^14.1.1"
}
}
EOF
echo "✅ Project \"$PROJECT\" created!"
echo " 📂 $PROJECT/"
echo " ├─ src/"
echo " │ ├─ index.html"
echo " │ ├─ style.css"
echo " │ └─ script.js"
echo " ├─ .vscode/launch.json"
echo " ├─ package.json"
echo " └─ .gitignore"
echo
echo "Next steps:"
echo " 1. cd $PROJECT"
echo " 2. npm install # install http-server (optional)"
echo " 3. npm start # serve on http://localhost:5500"
echo " 4. code . # open in VS Code"
echo
echo "Happy coding! 🎉"
How it works in brief:
Parses an optional project name (defaults to clock-timer).
Creates your folder structure:
src/ for HTML/CSS/JS
.vscode/launch.json for debugging with Chrome
package.json & npm start for a local server
Initializes a git repo and .gitignore.
Drops in minimal boilerplate for a digital clock that updates every second.
Prints next steps so you can jump right into coding (and debugging!) in VS Code.
Enjoy your new clock timer project! ⏰✨