Starting a new project

How to:

Let’s create a simple script to bootstrap a new project.


# Project setup script


# Function to create directories
make_directories() {
    mkdir -p $PROJECT_NAME/{bin,src,doc,test}
    echo "Directories created."

# Function to create initial files
make_files() {
    touch $PROJECT_NAME/
    touch $PROJECT_NAME/src/
    echo "#!/bin/bash" > $PROJECT_NAME/src/
    chmod +x $PROJECT_NAME/src/
    echo "Initial files created."

# Function to initialize a git repository
init_git() {
    git init
    cd $BASE_DIR
    echo "Git repository initialized."

# Main execution
if [ -z "$PROJECT_NAME" ]; then
    echo "Please specify a project name."
    echo "Project '$PROJECT_NAME' created."

Sample output after running bash myproject:

Directories created.
Initial files created.
Initialized empty Git repository in /path/to/myproject/.git/
Project 'myproject' created.

Deep Dive

Before we had scripts, we’d manually create directories and files every time—tedious and error-prone. Automation with a script minimizes mistakes and speeds things up.

Alternatives include tools like Yeoman, which scaffolds projects in various languages, but that’s like using a power drill when you need a thumbtack.

The script above is simple on purpose. It makes a project directory, subdirectories for organization (like src for source code), and essential files (like Plus, it sets up a Git repo so you can save versions of your work. You can tweak and add to it for each project’s needs.

See Also