Skip to content

Instantly share code, notes, and snippets.

@sordina
Last active February 28, 2016 23:34
Show Gist options
  • Save sordina/3d4cf513b6bd7e17a7b4 to your computer and use it in GitHub Desktop.
Save sordina/3d4cf513b6bd7e17a7b4 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
rawname=""
if [ "$1" == "-h" ] || [ "$1" == "--help" ]
then
echo "Usage: jekyll-new-draft.sh [DRAFT NAME WITH SPACES]" 1>&2
exit
fi
if [ "$1" ]
then
rawname="$*"
else
echo -n "Enter a new draft title: " 1>&2
read rawname
fi
if [ ! "$rawname" ]
then
echo "" 1>&2
exit
fi
filename="$(echo "$rawname" | sed -E 's/[ "()]+/_/g').markdown"
filepath="_drafts/$filename"
cat <<EOF > $filepath
---
layout: post
title: "$rawname"
categories: blog
---
<p class="attribution">
<img src="images/" class="image fit" />
<a href="">PHOTOGRAPHER</a> -
<a href="">"IMAGE TITLE"</a>
</p>
TEXT GOES HERE...
EOF
vim "$filepath"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment