-
-
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
This file contains 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
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