-
-
Save orta/1535206 to your computer and use it in GitHub Desktop.
my post script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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