Bash Blog

published

At work, there’s been an increased awareness of doing more of those things at which I excel, and less of the things at which I am not as competent. It’s basic economics, really: I get more and better output for less effort when I focus on my strengths.

That’s not to say there’s no value in trying to improve on some areas of deficiency; but unless such deficiencies are actively detrimental to my success, they should get less attention than the things at which I do better.

I’ve recently applied this knowledge to my blog. I had spent a lot of time writing a generic micropub framework in PHP in order to post content. I am not a particularly good programmer, so this effort was always harder than I felt it needed to be. I spent a lot of time making even simple things work as expected, and then spent even more time dealing with problems and edge cases.

I ended up trying to develop a generic solution, as opposed to a solution purpose built for me, which further complicated things as I tried to envision potential use cases instead of actual ones. I chased a lot of “what if” at the expense of stuff I actually wanted.

I’m a systems administrator by trade and training. I connect other people’s tools to produce new and interesting outputs. I am most fluent in shell scripting, and compositing UNIX pipelines to munge data in interesting ways. Anything I cobble together in PHP (or Ruby or Python) is going to be woefully incomplete when compared to the wealth of tools produced by the BSD and GNU communities.

UNIX is built on files. Blog posts are files. Using things like echo, cat, sed and grep I can manipulate content in a great variety of ways; and I don’t need to poorly reinvent any wheels or rediscover solutions to solved edge cases. The hard work of handling invalid input, error conditions, memory optimization, and the like has already been done by people much more competent than me!

It’s also the case that I carry in my pocket an extremely powerful computer. Previously, I’d used this pocket computer just to accept text input, and the occasional photo, from me and send it to my Linux server for processing. This is both inefficient and inelegant. My pocket computer can do a lot of work to prepare content for immediate use by my server.

So I’ve decided to play to my strengths, and stop working against them. I’ve written a new blog posting solution using GNU shell tools and bash, creatively called blog.sh. It works for me, and I don’t feel any particular reason to make a more generic solution. I found plenty of inspiration and guidance from other people’s code online, so maybe this purpose-built thing will help someone else solve their own particular problems in some way.

The blog.sh script is half of the solution. The other half is the iOS Shortcuts app. Using this simple programming solution, I can prompt myself for input, prep a valid YAML file, securely transfer it to my server, and then invoke the blog.sh script. I can also have my pocket computer resize images before transferring them, thereby reducing both transfer times and server-side image manipulation challenges.

I’ve stopped using Hugo. Rather than regenerate every post every time I publish something new, and dealing with the Golang templating language used by Hugo, I’m simply saving all my data as plain old Markdown files. I have a couple of simple HTML templates defined, and I rely on Caddy to render them when the page is requested.

Folks more comfortable with other tools might look at this setup and shake their heads in dismay. But this solution is more comfortable to me. It’s easy to test. It’s portable. I rely on those components that are pretty fundamental to a modern Linux system, and which are unlikely to change or break backwards compatibility. The only daemon process I have to manage is Caddy, which I need to serve pages at all anyway, so there’s no real overhead for me.

It also helps that I’ve decided to stop using Twitter. A large part of the motivation for my Micropub code was so that I could POSSE - “Post (on your) Own Site, Syndicate Elsewhere”. I don’t have a need to syndicate to Twitter any more, so I can stop worrying about all of those moving parts. I still present an RSS feed, for those who want to consume it.

I have been choosing not to write long form content for a long time, for a variety of reasons. Looking back at the rich body of blog content I’ve produced over the years has been informative and inspiring. Simplifying the process of posting content, and making it more comfortable for me to do so, will hopefully encourage me to produce more blog posts.

Brent Simmons’ recent post You choose helped me focus my thoughts on this matter a lot, too. I do choose to write, for myself, because I want to.


home / about / archive / RSS