January 2014

More Alfred and drush love

A couple years ago I started playing with using the stellar Alfred.app with drush to get things done. This post describes how I used a now defunct URL shortener to create short links from Alfred.

Fast forward a couple of years and Adjix is no longer but the basic script still works. However it had run into a couple of issues like being hard-coded to drush paths which can vary from machine to machine. This was because the non-interactive shell wasn't picking up all the wonderful things like my $PATH definitions in settings files. So a bit of work later and this script now looks like this:

#!/bin/bash
source ~/.bashrc
echo `drush .env ev 'print (shorten_url("{query}"));'`

That's it. Well there are two outputs of the workflow. The first copies the results of the statement to the clipboard. The other posts it to Notification Center so you know the work is done and get to see the URL for your shortened link.