Plausible Thought

April 1st, 2013

Creating new blog posts with an Alfred Workflow

One of my favourite new features of Alfred v2 is the new Workflows framework. It allows you to chain together scripts and actions based on a trigger.

I've created a Workflow that makes creating a new blog post quick and easy. I use Kirby so all my blog posts are stored in text files. I can now open Alfred, type post followed by the slug of the post I want to create and it will automatically do the following:

My Alfred blog post workflow

It works by running the following bash script:


# cd to blog folder
cd ~/Sites/plausiblethought/content/blog/

# count files
COUNT=$(ls | wc -l)

# make folder (e.g. 10-test)
mkdir $COUNT-{query}

# cd to folder created above
cd $COUNT-{query}

# get the date
DATE=`date "+%a, %d %b %Y %X"`

# create post.txt and fill it with blog post structure
echo "Title: 
‐‐‐‐
Date: $DATE
‐‐‐‐
Text:
" > post.txt

You can download the Workflow here.

Note: You'll need to modify the blog path in the bash script.

Hopefully you find it useful. I'm no bash expert, so I'd to love to hear feedback or suggestions. I'm on Twitter: @marcjenkins.

Update (03/04/13): Matthew Guay has tweaked the Workflow above and added some extra features. Check out his post: Publish to Kirby from Alfred.

Previously, on Plausible Thought

  1. How to add favicons to bookmarklets in Chrome
  2. Stop "fixing" WebKit font smoothing
  3. Drop down Terminal with iTerm2
  4. A new microsoft.com
  5. .htaccess in multiple Wordpress environments
  6. Microsoft's new logo
  7. Scratch: a quick-input notepad for iPhone
  8. Code Club: Inspire kids to learn to code
  9. Why you should pay too much for things
  10. Testing websites using the iOS Simulator