Day 22

A Bash Project Setup Tool

Unfortunately, you can't run this in the browser here

This is a shell script and must be run locally on a Unix-based system — it cannot run in the browser.

Run chmod +x setup.sh && ./setup.sh in your terminal to use it.


Description


A Bash script that scaffolds a new project directory. It prompts for a project name and language (Python, Go, React, or Rust), then creates the appropriate folder structure, starter files, a .gitignore, and initializes a git repository.

View the source code


#!/bin/bash

echo "Setup Project Directories Program"
echo
echo "What is the name of your project?"
read -p "> " name
echo "What is the project language?"
read -p "> " language

if [ "$language" = "python" ]; then
    mkdir "$name"
    cd "$name" || exit
    git init
    cat > main.py << 'EOF'
print('Hello, World!')
EOF
    python main.py
elif [ "$language" = "go" ]; then
    mkdir "$name"
    cd "$name" || exit
    git init
    go mod init "$name"
    touch main.go
    code main.go
elif [ "$language" = "react" ]; then
    npx create-react-app "$name"
    cd "$name" || exit
    code .
elif [ "$language" = "rust" ]; then
    cargo new "$name"
    cd "$name/src" || exit
    code main.rs
else
    echo "Language not supported"
fi

Previous Day  |  Next Day