#!/bin/sh

date=(`date +%F`)
subject=(`echo $@ | sed -e "s/ /-/g"`)
dir=~/sessions/${date}/${subject}
filename=${dir}/session
timingfile=${dir}/timing

currentdir=`pwd`

#echo Recording session $1 as $filename

if [ ! -d "${dir}" ] ; then
    mkdir -p "${dir}"
fi

script -f ${filename} --timing=${timingfile}

cd ~/sessions
if [ -d .git ] ; then
    git add ${dir}
    git commit
fi

cd $currentdir
