Skip to content

Instantly share code, notes, and snippets.

@johanbove
Forked from metaskills/gist:6414713
Last active August 29, 2015 14:25
Show Gist options
  • Save johanbove/3e3a1659067b98835780 to your computer and use it in GitHub Desktop.
Save johanbove/3e3a1659067b98835780 to your computer and use it in GitHub Desktop.
Jekyll tasks/post to help create a new post.

Works on Windows using Git shell;

  1. Save the shell script in the "\tasks" folder on your blog.
  2. Use command to execute: sh .\tasks\post.sh "A Brilliant Post"

The last line will open the new post in Brackets.

#!/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
brackets $post
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment