Created
September 2, 2013 16:30
-
-
Save metaskills/6414713 to your computer and use it in GitHub Desktop.
Jekyll tasks/post to help create a new post.
This file contains hidden or 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
#!/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
You could also use thor, if you have other tasks as well: https://github.com/tpitale/tpitale.github.com/blob/master/tasks/post.thor