Skip to content

Instantly share code, notes, and snippets.

@timlockridge
Forked from pibby/jekyll-bash-new-post
Last active March 24, 2018 01:00
Show Gist options
  • Save timlockridge/5b4c4e110a228e48fa820caa43cd5310 to your computer and use it in GitHub Desktop.
Save timlockridge/5b4c4e110a228e48fa820caa43cd5310 to your computer and use it in GitHub Desktop.
This bash function script will setup a new Jekyll blog post in Markdown and open it for editing in Atom
function new-post() {
#!/bin/bash
# Original by Katie Harron - @pibby // Hacked on by Tim Lockridge
# This bash script will setup a new Jekyll blog post in Markdown and open it for editing in Atom
echo "Post Title: "
read title
ptitle=${title// /-} # convert spaces in title to hyphens
plc=`echo "$ptitle" | tr '[:upper:]' '[:lower:]'` # convert title to lowercase
pdate=`date +%Y-%m-%d` # create date as Year-Month-Date
tstamp=$(date +"%Y-%m-%d %H:%M:%S") # create timestamp as Year-Month-Date Hour:Min:Second
filename=~/Github/timlockridgedotcom/_posts/$pdate-$plc.md # location to create the new file as year-month-day-title.md
touch $filename # create the new blank post
echo "---
layout: post
title: $title
date: $tstamp
comments: true
---" > $filename # fill out YAML Front Matter and insert into our new file
atom $filename # open in Atom
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment