blog/scripts/new.sh

22 lines
456 B
Bash
Raw Normal View History

2023-10-25 13:14:23 +09:00
#!/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