Skip to content

Instantly share code, notes, and snippets.

@digizeph
Created August 23, 2015 20:05
Show Gist options
  • Select an option

  • Save digizeph/b0b3fe5388e398e09924 to your computer and use it in GitHub Desktop.

Select an option

Save digizeph/b0b3fe5388e398e09924 to your computer and use it in GitHub Desktop.
#!/bin/bash
####
## read in fields
####
echo "Title:"
read -e title
echo ""
echo "Filename:"
read -e fname
echo ""
if [ -z "$fname" ]
then
fname=$title
fi
# change to lower case and replace spaces with '-'
fname=`echo $fname| tr "[:upper:]" "[:lower:]" | tr " " "-"`
echo "Categories:"
read -e categories
echo ""
echo "Tags:"
read -e tags
echo ""
NAME="`date +%F`-$fname.md"
if [ -e $NAME ]
then
echo "File $NAME exists already, exit now."
echo ""
exit 1
fi
cat > $NAME << ENDOFFILE
---
layout: post
title: "$title"
categories: [$categories]
tags: [$tags]
comments: True
---
ENDOFFILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment