#!/bin/bash

TITLE="changeme"
DATE=$(date +%Y-%m-%d)
FILE="$DATE-$TITLE.md"

if [ ! -f content/posts/$FILE ]; then
	echo Creating new file $FILE
	cp content/posts/2000-01-01-draft.md content/posts/$FILE
	sed -i "s/date = 2000-01-01T00:00:00Z/date = $(date -Isec)/g" content/posts/$FILE 
fi

if [ $( command -v subl ) ]; then
	subl $FILE
elif [ $( command -v gedit ) ]; then
	gedit $FILE
elif [ $( command -v vim ) ]; then
	vim $FILE
else
	$EDITOR $FILE
fi
