Basic blot blogging from the command-line
Posting to my blog is a breeze from mobile thanks to a couple shortcuts and Drafts actions I’ve put together. I wanted posting to be just as seemless from my computer, too. Here is my quick and dirty solution!
#!/usr/bin/env bash
cd "$(dirname "$0")" # Go to the script's directory
DATE=$(date +%Y-%m-%d-%H-%M)
# The paths to your blot website's draft and post directories
DRAFT_DIR=/Users/someuser/Dropbox/Apps/Blot/drafts/
POST_DIR=/Users/someuser/Dropbox/Apps/Blot/posts/
USER_INPUT="$@"
# Your editor of choice
EDITOR='emacs'
if [ -n "$USER_INPUT" ]; then
if [ $USER_INPUT == "post" ]; then
printf "title: \ndate: ${DATE}\ntags: " > ${POST_DIR}${DATE}.md
$EDITOR ${POST_DIR}$DATE.md
fi
if [ $USER_INPUT == "draft" ]; then
printf "title: \ndate: ${DATE}\ntags: " > ${DRAFT_DIR}${DATE}.md
$EDITOR ${DRAFT_DIR}$DATE.md
fi
else
printf '\nBlot blogging from the command-line.\n\n draft create a draft post\n post live dangerously and just post that sucker!\n\n'
fi
In the future I may expand this to support editing existing posts, too. I’ve also been toying with a way to do this without ever leaving emacs.
Published