Skip to content

Instantly share code, notes, and snippets.

@brunokoga
Forked from metaskills/gist:6414713
Created December 18, 2013 10:58
Show Gist options
  • Save brunokoga/8020513 to your computer and use it in GitHub Desktop.
Save brunokoga/8020513 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