Skip to content

Instantly share code, notes, and snippets.

@rigelk
Last active August 29, 2015 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rigelk/8770430 to your computer and use it in GitHub Desktop.
Save rigelk/8770430 to your computer and use it in GitHub Desktop.
jekyll post generator
#!/bin/bash
# Author: Pierre-Antoine Rault (rigelk)
# Sauce: https://gist.github.com/rigelk
# Licence: BSD licence
usage="USAGE ./new_event [editor]"
if [ $1 ]
then
read -r -p "Post name > "
title=${REPLY}
read -r -p "Category > "
cat=${REPLY}
title_clean="$(<<< "$title" \
iconv -f utf8 -t ascii//translit \
| tr ' [:upper:]' '-[:lower:]' \
| tr -dc 'a-z0-9._-')"
filename="_posts/$(date "+%Y-%m-%d")-$title_clean.md"
echo "---
layout: post
title: $title
categories: $cat
---" > "$filename"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment