(define sixhat (λ (dave) (display 'ideas)))

My approach to managing scratch projects with bash scripts

In R if I just want to test an idea I create a scratch project in /tmp . This will removed automatically on the next boot. This makes it easy to setup scratch folders without leaving much clutter behind. The problem is that the next time you open R after a reboot it will complaint about not finding the previous workspace. I also do the same thing with Markdown files and folders. To help me manage this I have a new_project bash script in my bin folder that goes like this (only .r and .md versions shown but can easily be extended for your needs)

#!/bin/bash
set -euo pipefail

__usage="usage: new_project name <type>

    type can be one of md, r, or any other... and accordingly it should open 
    and setup different folder structures

    name will be the folder name where the project exists.
"

make_folder () {
    mkdir -p "$1"
    cd "$1"
}

project_md (){
    make_folder "$1"
    local today_file="$(date +%F).md"
    if test ! -f "$today_file"; then
        touch "$today_file"
    fi
    open -a "/Applications/Visual Studio Code.app/" "$today_file"
}

project_r (){
    make_folder "$1"
    local today_file="$(date +%F).r"
    if test ! -f "$today_file"; then
        touch "$today_file"
    fi
    open -a "/Applications/RStudio.app" "$today_file"
}

# Start logic bellow this line

if [ "$#" != 2 ]; then
    echo "$__usage"
    exit 1
fi

if [ "$2" = "r" ]; then
    project_r $1
fi

if [ "$2" = "md" ]; then
    project_md $1
fi