Skip to content

Instantly share code, notes, and snippets.

@harsh183
Created May 22, 2019 16:02
Show Gist options
  • Save harsh183/7ff9948dfd82576a40d19b0496a022f9 to your computer and use it in GitHub Desktop.
Save harsh183/7ff9948dfd82576a40d19b0496a022f9 to your computer and use it in GitHub Desktop.
#!bin/bash
# Usage:
# bash jekyll_new.sh file_title
# Example:
# bash jekyll_new.sh daily-angst
# This script is for creating a new jeykll post under _posts/
# Change as needed
cd _posts
# Ex. 2019-04-14
DATE=`date +%Y-%m-%d`
EXTENTION='.md'
# Ex. 2019-04-14-daily-angst.md
FILE_NAME="$DATE-$1$EXTENTION"
if test -f "$FILE_NAME"
then
echo "File exists. Opening existing"
else
# Simple template
echo "---
layout: post
title:
---" >> $FILE_NAME
fi
vim $FILE_NAME
git add $FILE_NAME
@harsh183
Copy link
Author

Note this is also with vim in mind but change that to whatever text editor you use.

Also assumes you have been using it with git and are running this in the base jekyll directory.

@harsh183
Copy link
Author

MIT License

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