Created
February 7, 2018 07:41
-
-
Save jacobwyke/3b99fa6175982e08603df2ae74a352cd to your computer and use it in GitHub Desktop.
Bash script to add a new Jekyll post with the correct file name and front matter
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
#!/bin/bash | |
strBaseFolder=`pwd`/ | |
strDate=`date +"%Y-%m-%d"` | |
strTime=`date +"%H:%M:%S %z"` | |
if [ "$#" == 0 ] || [ "$#" -gt 1 ] ; then | |
echo "Usage: $0 'post title'" | |
exit; | |
fi | |
strTitle=$1 | |
strCleanTitle=`echo $strTitle | sed -e 's/ /-/g' | tr '[:upper:]' '[:lower:]'` | |
strFilename="$strBaseFolder$strDate-$strCleanTitle.md" | |
#write the new post file | |
read -d '' content <<EOL | |
--- | |
layout: post | |
title: $strTitle | |
date: $strDate $strTime | |
--- | |
EOL | |
echo "$content" >> $strFilename |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment