Skip to content

Instantly share code, notes, and snippets.

@orta
Created December 29, 2011 17:44
Show Gist options
  • Save orta/1535206 to your computer and use it in GitHub Desktop.
Save orta/1535206 to your computer and use it in GitHub Desktop.
my post script
#!/bin/bash
set -e
EDITOR=slime
TITLE=${1}
POSTDIR=_posts
EDITDIR=edit
cd /Users/orta/spiel/html/rebase
if [ ! -n "${TITLE}" ] || [ -n "${2}" ]
then
echo "USAGE: ${0} 'Title of my Blog Super-Post!'"
exit 1
fi
SLUG=`echo "${TITLE}" \
| tr '[A-Z]' '[a-z]' \
| tr ' ' '-' \
| sed 's/[^a-zA-Z0-9\-]/-/g' \
| sed 's/-\+/-/g' \
| sed -e 's/^-//g' -e 's/-$//g'`
FILE=`date '+%Y-%m-%d'`-${SLUG}.textile
EDFILE=${EDITDIR}/${SLUG}.textile
if [ ! -e ${POSTDIR}/${FILE} ]
then
mkdir -p "${POSTDIR}"
cat - > /tmp/${FILE} << EOF
---
layout: post
title: `echo ${TITLE}`
categories:
- "on"
updated_at: `date +'%Y-%m-%d'`
uuid: `uuidgen`
---
HEY YOU: Remember to write something.
EOF
cat /tmp/${FILE}
mv /tmp/${FILE} ${POSTDIR}/${FILE}
fi
$EDITOR /Users/orta/spiel/html/rebase
echo "Saved ${EDFILE}."
cd /Users/orta/spiel/html/rebase
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment