Skip to content

Instantly share code, notes, and snippets.

@mattvagni
Created December 15, 2014 12:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattvagni/f14b6e03e2873e1764a1 to your computer and use it in GitHub Desktop.
Save mattvagni/f14b6e03e2873e1764a1 to your computer and use it in GitHub Desktop.
START_DIR=`pwd`
DIR="$(cd "$(dirname "$0")" && pwd)"
cd $DIR
echo -n "What's the post title?: "
read -e TITLE
# Convert to lowercase, remove punctiuation & convert spaces to Hyphens
SLUG=`echo $TITLE | tr '[:upper:]' '[:lower:]' | tr -d '[:punct:]' | tr '[:blank:]' '-'`
FILENAME_DATE=`date +"%Y-%m-%d"`
POST_DATE=`date +"%y-%m-%d %H:%M:%S"`
POST=../_posts/$FILENAME_DATE-$SLUG.md
# Make Post
touch $POST
# Create Front-matter
echo '---' >> $POST
echo 'layout: post' >> $POST
echo 'title:' $TITLE >> $POST
echo 'date:' $POST_DATE >> $POST
echo 'excerpt:' >> $POST
echo '---' >> $POST
subl $POST
# Go back to where we started.
cd $START_DIR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment