40 lines
610 B
Bash
Executable File
40 lines
610 B
Bash
Executable File
#!/bin/bash
|
|
|
|
set -eux
|
|
|
|
TODAY="$(date +'%Y%m%d')"
|
|
DATETIME="$(date +'%F %H:%M')"
|
|
POSTPATH="content/posts/${TODAY}.md"
|
|
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
|
|
|
|
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
|