Skip to content

Instantly share code, notes, and snippets.

@itspriddle
Created March 14, 2010 23:24
Show Gist options
  • Save itspriddle/332331 to your computer and use it in GitHub Desktop.
Save itspriddle/332331 to your computer and use it in GitHub Desktop.
#!/bin/bash
usage()
{
cat <<USAGE
./_script/generate post
USAGE
exit 42
}
new_post()
{
echo _posts/`date "+%F"`-`echo $1 | tr [A-Z] [a-z] | sed 's/ /-/g'`.markdown
cat <<TEMPLATE > _posts/`date "+%F"`-`echo $1 | sed 's/ /-/g' | tr [A-Z] [a-z]`.markdown
---
layout: post
title: $1
date: `date`
categories:
- Development
---
TEMPLATE
}
# Called
if [ $# -eq 0 ] || [ "$0" != "./_script/generate" ]; then
usage
fi
case "$1" in
post)
new_post "${POST_TITLE:=New Post}"
;;
*)
usage
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment