Skip to content

Instantly share code, notes, and snippets.

@faun
Forked from metaskills/gist:6414713
Created September 2, 2013 23:11
Show Gist options
  • Save faun/6418077 to your computer and use it in GitHub Desktop.
Save faun/6418077 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
if [ -z "$1" ]; then
echo "Usage: provide a title argument."
exit -1
else
title="$@"
fi
d=$(date +"%Y-%m-%d")
slug=$(echo $title | tr '[:upper:]' '[:lower:]' | tr '[:space:]' '-')
slug="${slug:0:${#slug}-1}"
post="./_posts/$d-$slug.md"
body=""
read -d '' body <<EOF
---
layout: post
title: $title
categories:
-
---
EOF
echo "$body" > $post
subl . $post
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment