Skip to content

Instantly share code, notes, and snippets.

@pibby
Last active May 16, 2021 23:16
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save pibby/6911493 to your computer and use it in GitHub Desktop.
Save pibby/6911493 to your computer and use it in GitHub Desktop.
This bash script will setup a new Jekyll blog post in Markdown and open it for editing in Sublime Text 2
#!/bin/bash
# Katie Harron - @pibby
# This bash script will setup a new Jekyll blog post in Markdown and open it for editing in Sublime Text 2
echo "Post Title: "
read title
echo "Post Description: "
read desc
echo "Post Tags: "
read tags
echo "Post Keywords: "
read keyw
echo "Banner image (bg_ .jpg): "
read img
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
filename=~/Sites/katieharron/_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
description: $desc
categories: articles
date: $pdate
tags: [$tags]
keywords: [$keyw]
image: $img
---" > $filename # fill out YAML Front Matter and insert into our new file
/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl $filename # open in Sublime Text 2 (Mac OS X)
@mslinn
Copy link

mslinn commented Aug 16, 2020

Katie,

Hope you find my modifications to your script useful.
Would you be agreeable to applying the Apache 2 license?
All that would be required would be to include this at the top of the script:

# SPDX-License-Identifier: Apache-2.0

I have already done this to my version, but unless you do the same I cannot publish that change.

Thanks,
Mike

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment