Writing a simple script to create blog posts

by Tim

I've been trying to write more and more scripts to automate as much as possible. That is the point of technology after all, isn't it? Plus I'm lazy, and have a bad memory, so I always forget what the YAML frontmatter is supposed to look like. And then I have to type in the date. UGH.

So, just a short python script to create the file, and then bring up vim so I can edit the file.

#!/bin/python3
if __name__ == '__main__':
    from datetime import date
    from subprocess import call

    d = date.today()
    filename = str(d) + ".md"

    frontmatter = """+++
title = "x"
date = {0}
+++

"""

    frontmatter = frontmatter.format(d)

    with open(filename, 'w') as f:
        f.write(frontmatter)
    call(['vim', filename])

Nothing fancy, nothing special, but just something I wanted to share. Saves me a few seconds, but I'm planning on using it every day, so it's worth it.