2015-11-06 02:44:47 +00:00
|
|
|
#!/bin/sh
|
2015-03-10 01:35:13 +00:00
|
|
|
read -ep 'Title of new post: ' TITLE
|
|
|
|
read -ep 'Tags for new post, comma-separated: ' TAGS
|
2015-03-10 00:55:45 +00:00
|
|
|
DATE=`date '+%Y-%m-%d %H:%M'`
|
2015-03-10 01:35:13 +00:00
|
|
|
FNAME="`date '+%Y%m%d'`.`echo "$TITLE"|tr '[:upper:]' '[:lower:]'|tr -cd '[:alnum:]'`.md"
|
2015-03-09 00:58:08 +00:00
|
|
|
cp posts/post.template posts/$FNAME
|
2015-03-10 01:35:13 +00:00
|
|
|
env V="$TITLE" perl -pi -e 's/^(title: )/$1$ENV{V}/' posts/$FNAME
|
|
|
|
env V="$DATE" perl -pi -e 's/^(date: )/$1$ENV{V}/' posts/$FNAME
|
|
|
|
env V="$TAGS" perl -pi -e 's/^(tags: )/$1$ENV{V}/' posts/$FNAME
|
2015-03-10 00:55:45 +00:00
|
|
|
[ -z "$EDITOR" ] && echo "EDITOR environment variable not set. Please set this to your preferred editor, or open $FNAME manually" && exit
|
2015-03-09 00:58:08 +00:00
|
|
|
$EDITOR posts/$FNAME
|