As I’ve gotten used to writing my blog posts, I’ve been tweaking my workflow to speed things up.

Creating a new draft

Whenever I’ve needed to start a new draft of a blog post within my new workflow, I’ve followed a number of steps:

  • Create a new sub-folder in my drafts folder.
  • Create a MarkDown file with the same name as the folder.
  • Initiate a new repository.

Simple steps, but I start a lot of posts and have a lot of things in draft. So I decided to write a simple Shell script that would do these for me, called newdraft.sh:

# Set up new draft folder with pre-requisite templates.
cd ./drafts
mkdir $1
cd $1
touch $1.md
touch tags.txt
git init
git add $1.md
git add tags.txt
git commit -m "Added template files to begin writing."

Automating metadata for Scriptogram

One of the things I also need to do usually is create a metascrp.txt file that will contain the fields needed for posting to Scriptogram, as mentioned in a previous post.

So I wrote a short script called create_metascrp.sh that would write this file for me, pulling the title as the first level 1 header in the file and automating the date on publish.

It takes the tags from a file called tags.txt converting tags an multiple lines to a single-line comma-delimited list.

The entire code for the script is here:

header=$(grep -E --max-count=1 '^\#[^#]*?$' $1.md)
bareheader=${header#\# }
contents=$(grep -Ev '^\#[^#]*?$' $1.md)
tagsraw=$(<tags.txt)
tags=${tagsraw//$' '/', '}
metadata=$(echo -e "Title: $bareheader Date: $(date '+%F %H:%M') Published: True Tags: $tags ")
echo -e "$metadata" > metascrp.txt

I committed both these files to my Git repository for the model and pushed them to GitHub today as version 0.0.2, the model still being very much undecided and therefore unstable.

What next?

I still need to manually remove level 1 headers from my posts after I have created the metadata, to stop them displaying twice in Scriptogram. Doing that manually is tedious so I will automate that soon.

But, although that sounds simple, it needs to sit within an overall “publish” script that takes care of pushing to Scriptogram, and of preserving my content in a channel-neutral way offline. I am already looking into this and should post something on it soon.