Extending Alfred
27 Oct 2012A friend finally got Alfred and was excited to see some of the extensions available. I had dismissed a lot of these as just tools I would never use, that was until I saw a couple that got me thinking. The first one is called Open Terminal Here, which opens the terminal to the location of the front most finder window. The second extension is called Using Alfred to clone a github repository.
My general workflow goes something like this
- Clone something to my tmp directory*
- Get into the directory
- Open in some editor
*I have a habit of sticking everything in
/tmp
otherwise I end up with lots of clutter that I will never find the time to remove
The extension I want is essentially the love child of the two that I have mentioned. This is what I came up with
This is horrible Applescript which I normally try and avoid with a 10ft barge pole but it got the job done.
Line 1 and 9 enable us to get the parameter passed into Alfred which will be a git url.
Line 5 uses ruby to get the gems name so we can create a directory with the correct name and cd into it
Line 6 Uses terminal to get us into the /tmp
directory, clones the repo and then gets us into the new directory
##Conclusion
It’s by no means perfect but it gets the job done allowing me to try things out and automating the steps I normally take.