DEV-DIARIES

NiceBSD Dev Diary 2015-03-05

Spending today getting a whole bunch of helper scripts done. I’ve got a soft spot for those little scripts that are 3-4 lines that become so much a part of your workflow that you don’t even notice how they’ve entered your muscle memory vocabulary when you whip through a project. These scripts never seem to qualify as ‘programming’ proper, and are seldom held up as examples when a newcomer enters the field and asks ‘what are some good examples to read from?’ But I think they are essential if you are serious about ‘making the computer do the work.’

Take for example the script that I now use to make these blog posts. Here’s the code:

#!/bin/sh
DATE=$(date +%Y-%m-%d)
TEMPLATE=~/src/blog/drafts/nicebsd-dev-diary-template.rst
DEST=~/src/blog/posts/nicebsd-dev-diary-$DATE.rst

# Do a non-clobber copy
cp -n $TEMPLATE $DEST
# Replace DATE with an autogenerated date
sed -i "s/DATE/$DATE/" "$DEST"
# Open in a text editor
"$EDITOR" "$DEST"

Now this is a pretty simple script (perhaps a bit over-engineered), and yet I’m quite happy with it. When I want to write a blog post, I just want to get my ideas down and move on. I don’t want to deal with the incidental complexity of ‘did I get the datestamps correct?’ So when I wanted to make this post, I just typed ./dev-diary and I was writing instantly. It took about 5 minutes to write and test the script, but I’ll almost never need to touch it again, and any future maintenance should be quite easy.

It reminds me a bit of Stewart Brand’s ’low road building’ episode of How Buildings Learn. These scripts may not be pretty, or are too specialized to be of use to anyone else. However, they make for an overall happier computing experience - a happiness that often you can’t get for $4.99 from the app store.

These scripts I’m writing you’ll probably never see, but that’s fine, because the stuff that you will end up seeing will be produced faster and better as a result.