2022-02-24 06:55:41 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -eux
|
|
|
|
|
|
|
|
TODAY="$(date +'%Y%m%d')"
|
|
|
|
DATETIME="$(date +'%F %H:%M')"
|
|
|
|
PUBDATE="$(date +'%F %H:%M %Z')"
|
|
|
|
TITLE="$@"
|
|
|
|
if [ -z "$TITLE" ]
|
|
|
|
then
|
|
|
|
TITLE="${TODAY}"
|
|
|
|
SLUG="${TITLE}"
|
|
|
|
else
|
|
|
|
TITLE="$@"
|
|
|
|
SLUG="$(echo ${TITLE}|tr [A-Z] [a-z]|tr ' ' '-')"
|
|
|
|
fi
|
|
|
|
|
2022-02-24 07:35:27 +00:00
|
|
|
POSTPATH="content/posts/${SLUG}.md"
|
2022-02-24 06:55:41 +00:00
|
|
|
if [ ! -e "${POSTPATH}" ]
|
|
|
|
then
|
|
|
|
cat <<EOF > ${POSTPATH}
|
|
|
|
Title: ${TITLE}
|
|
|
|
Slug: ${SLUG}
|
|
|
|
Date: $(date +'%F')
|
|
|
|
Modified: $(date +'%F')
|
|
|
|
Category:
|
|
|
|
Tags:
|
|
|
|
Authors: kyle
|
|
|
|
Summary:
|
|
|
|
EOF
|
|
|
|
else
|
|
|
|
sed -i -e "s/Modified: .*$/Modified: ${PUBDATE}/" $POSTPATH
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
#EDITOR="$(command -v em)"
|
|
|
|
|
|
|
|
EDITOR="${EDITOR:-gvim}"
|
|
|
|
$EDITOR $POSTPATH
|