I spent a lot of this weekend playing and setting up Alfred to automate all the things. I also met with Allena and Justine from the #100devs crew and we talked about blogging as a means of getting yourself out there and showing people how you work & how you think. The irony that I hadn’t updated my own blog in a while was not lost on me.
Getting a new post going with a static-site generator involves running a command, setting up front matter (the YAML at the top), possibly creating a directory, moving images into it, adding the markup for those images, and of course, writing the post itself. If I’m going to post regularly I need at least some of that friction to go away.
So I added a workflow to Alfred that does just that. No laughing. I haven’t written a shell script in a minute.
# get into the blog directory
# create a directory for the new post
# move into the new directory
# copy the template up for a regular post
cp ../../../templates/post.md ./index.md
# swap out the date
/usr/local/bin/sd 'YYYY-MM-DD' $(date +"%Y-%m-%d") ./index.md
# swap out the slug
/usr/local/bin/sd 'post-slug' $query ./index.md
# launch code putting me right into the body of the new post
/usr/local/bin/code . --goto ./index.md:10
I’ll skip the play by play since you’ve got comments to read, but with one command I get dumped right into an editor on the line where I can start typing whatever it is that I want to post. A little front-matter editing after I’m done and it’s ready to be posted.