Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
This bash script will setup a new Jekyll blog post in Markdown and open it for editing in Sublime Text 2
#!/bin/bash
# Katie Harron - @pibby
# This bash script will setup a new Jekyll blog post in Markdown and open it for editing in Sublime Text 2
echo "Post Title: "
read title
echo "Post Description: "
read desc
echo "Post Tags: "
read tags
echo "Post Keywords: "
read keyw
echo "Banner image (bg_ .jpg): "
read img
ptitle=${title// /-} # convert spaces in title to hyphens
plc=`echo "$ptitle" | tr '[:upper:]' '[:lower:]'` # convert title to lowercase
pdate=`date +%Y-%m-%d` # create date as Year-Month-Date
filename=~/Sites/katieharron/_posts/$pdate-$plc.md # location to create the new file as year-month-day-title.md
touch $filename # create the new blank post
echo "---
layout: post
title: $title
description: $desc
categories: articles
date: $pdate
tags: [$tags]
keywords: [$keyw]
image: $img
---" > $filename # fill out YAML Front Matter and insert into our new file
/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl $filename # open in Sublime Text 2 (Mac OS X)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment