From 79933cb60b979453b480be46a078be08e988bab4 Mon Sep 17 00:00:00 2001 From: Matthew Connelly Date: Tue, 10 Mar 2015 00:55:45 +0000 Subject: [PATCH] maybe finished the new post script --- scripts/new-post | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/new-post b/scripts/new-post index fb8d0d5..5822b0f 100644 --- a/scripts/new-post +++ b/scripts/new-post @@ -1,7 +1,11 @@ #!/usr/bin/env bash TITLE=`read -e -p 'Title of new post: '` TAGS=`read -e -p 'Tags for new post, comma-separated: '` +DATE=`date '+%Y-%m-%d %H:%M'` FNAME="`date '+%Y%m%d'`.`echo "$TITLE"|tr -cd '[:alnum:]'`.md" cp posts/post.template posts/$FNAME -[ -z "$EDITOR" ] && echo "EDITOR environment variable not set. Please set this to your preferred editor, or open $FNAME manually" +perl -pi -e 's/^(title: )/$1\Q'$TITLE'\E//' posts/$FNAME +perl -pi -e 's/^(date: )/$1\Q'$DATE'\E//' posts/$FNAME +perl -pi -e 's/^(tags: )/$1\Q'$TAGS'\E//' posts/$FNAME +[ -z "$EDITOR" ] && echo "EDITOR environment variable not set. Please set this to your preferred editor, or open $FNAME manually" && exit $EDITOR posts/$FNAME