Jekyll, the static site compiler powering this blog, comes with a nice draft
feature for some time now. Draft posts are placed into the
instead of the normal
_posts directory and built and served only if a special
flag is passed to Jekyll. After using this for some time now, it became a real
chore to name and rename the files according to the proper Jekyll conventions
_posts/2013-23-12-foo-bar-baz.md). Of course, I had to do something
about it …
Using this tiny script, I can now create regular posts or drafts with the YAML header simply by writing
$ jk post A post about this $ jk draft A draft about that
Furthermore, I can move posts between both directories, identifying the file in question via a simple fuzzy search1, e.g.
$ jk switch about that Moved _drafts/2013-12-30-a-draft-about-that.md -> _posts/2014-01-08-a-draft-about-that.md
moves the post to the drafts directory. The same mechanics is used to edit a file, e.g. Vim is launched for the draft if, I run
$ jk edit about that
The implementation is questionable but it works fine for me.