posted on Tue, Nov 03 '15 under tag: code

I started using jekyll for this feed aggregation and I couldn’t make myself write the weird date format in jekyll front matter. That’s how I came up with this simple snippet that creates a file automatically with the YAML front matter for jekyll.

function jeknew
    if [ -d "_posts" ]
        set JekyllFileName (echo (date +"%Y-%m-%d") (echo $argv).md | sed 's/ /-/g' | sed 's/.*/\L&/')
        echo Creating $JekyllFileName
        set JekyllDate (date +"%Y-%m-%d %H:%M:%S %z")
        echo "---
layout: post
title: $argv
date: $JekyllDate
---" >> _posts/$JekyllFileName
        echo "No _posts directory. Are you in a jekyll folder?"

I run it like

$ jeknew Post Title

Like what you are reading? Subscribe (by RSS, email, mastodon, or telegram)!