#!/bin/bash # pickmy.org post composer # by: Jay/nq4t/@music_onhold # usage: ./compose.sh [category] [title] # example: /compose.sh blog MY AWESOME BLOG TITLE NO YOU DON'T NEED TO ENCLOSE IT! # run in the root of your site files/repository # assumes categories are directories in root # Arguments and Variables category=$1 pd=$(date +'%Y-%m-%d') pt=$(date +'%T') file=blog$$.md title=$2 # I'm lazy. I want every indvidual word after # the first one to be the title. No special # characters. Just cycle through them. shift 2 for word in "$@" do title="$title $1"; shift 1; done # Let's write the front matter to our file. printf -- "---\ntitle: $title\nlayout: post\ndate: $pd $pt\nexcerpt_separator: \n---\n" >> $file # Write the post in nano. nano + $file # Rename the file and copy the post to the right directory. t=${title,,} mv $file $category/_posts/$pd-${t// /-}.md printf "\nPost $title created in $category: $category/_posts/$pd-${t// /-}.md\n\n"