Last active
February 28, 2017 07:43
-
-
Save xianny/59698c917c664aca4eec89b199d4f793 to your computer and use it in GitHub Desktop.
jekyll-new-post
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 | |
# This script creates a new post or draft in jekyll with pre-filled front matter | |
# ./script some title for your post | |
# use -d option for draft | |
FILEDIR="_posts/" | |
while getopts "d" opt; do | |
case $opt in | |
d) | |
FILEDIR="_drafts/" | |
;; | |
esac | |
done | |
shift $((OPTIND-1)) | |
TITLE="" | |
for word in $@ | |
do | |
TITLE+="-$word" | |
done | |
FILENAME="$FILEDIR$(date +%Y-%m-%d)$TITLE.md" | |
echo "---" > $FILENAME | |
if [ $# -gt 0 ] | |
then | |
echo "title: \"$@\"" >> $FILENAME | |
fi | |
echo "layout: post" >> $FILENAME | |
echo "date: $(date +%Y-%m-%d) $(date +%T) $(date +%z)" >> $FILENAME | |
echo "tags: " >> $FILENAME | |
echo "categories: " >> $FILENAME | |
echo "---" >> $FILENAME | |
gedit $FILENAME & |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ahh! I had been thinking of writing something like this...I'm so glad you did!! >< awesome job!