#!/bin/sh

# DATE Format: DAY-DD-MM-YY
# date (1p) format:
STAMP="$(date +"%A-%d-%B-%Y")"
# TMP
TMP="${HOME}/tmp"
# Working Directory
DIR="${TMP}/${STAMP}"
# Default Tmux Session name
NAME=${1:-"scratch"}

# If the directory is non-existent then create it
[ ! -d "${DIR}" ] && mkdir -p "${DIR}"

# Create a new tmux session with the $NAME name and $DIR as working directory
{ tmux -q has-session -t "${NAME}" && exec tmux attach-session -t "${NAME}"; } \
  || exec tmux new-session -n "${NAME}" -s "${NAME}" -c "${DIR}"

exit $?
