##Date: 29/03/2020 Tags: Apple, Software & services Permalink: 2020/03/29/how-to-install-an-applescript-and-save-a-lot-of-time-writing-blog-posts
How to install an AppleScript and save a lot of time writing blog posts
AppleScript is something I’ve always knew by name, but never really got into it. I know it is a language used to build tiny programs on top of MacOS, to automate some tasks, to create shortcuts, basically to do things computers are supposed to do in the first place: compute things.
I am not even sure if what I will be describing below is technically an AppleScript, or a program, or an app, or whatever, but for the sake of simplicity, let’s say it is an AppleScript. Forgive me if I butcher the terminology in this post.
Having recently switch to Drafts and optimised it with a few Markdown shortcuts native to the app, I decided to take things one step further and optimise my MacOS workflow itself. Nothing too fancy, nothing too complicated. I only had one AppleScript in mind, one I’ve heard John Gruber mention once on The Talk Show: a script to quickly paste opened Safari tabs URLs into the document you’re working on.
This tool allows you to do it with a couple of keystrokes and clicks only; which is way faster than respectively switching apps, going to the URL bar, copying the URL, switching back apps, and finally pasting. And the more URLs you need to paste, the more useful the script becomes.
Gruber has generously made the code available on Github: Paste URL From Safari Tab — so, how does it work? I struggled a little myself finding the information I needed to make everything work perfectly, so I thought I’d share a simple step-by-step guide for beginners like me.
Installing an AppleScript in 10 easy steps on MacOS
This should take 2 or 3 minutes.
- Copy the code
- Open the Automator app (the use of Spotlight to find it is recommended), and create a new file.
- Choose Quick Action, and select “no input” in front of “Workflow receives current”
- On the left column, look for Run AppleScript by using the search field, then double click on it: a new box should appear in the main panel.
- Replace the code inside this box with the one you copied earlier, and then save the Automator file. Use a simple, recognisable name.
- Go to your computer’s System Preferences, and select Keyboard > Shortcuts > Services.
- At the bottom of the list, you should find the Automator file you just created: you can now add a shortcut to it (I used “cmd alt colon“ for the Gruber script for instance).
- Now, one last step: go back to the System Preferences main screen and select Security & Privacy.
- Now select Privacy, and then Accessibility. From there you have to add Automator to the list of apps allowed, by clicking the “plus” button at the bottom of the list (you may need to click on the lock first), along with all the apps you want to use the script with (for the previously mentioned script, my allowed apps are Drafts and Tweetbot)
- Once all these steps are completed, you can try your shortcut; the first time you will use the script, you will have to click “OK” a couple of times, and you’re good forever.
And voilà: the quick-access list of your Safari tabs, with their URLs ready to be pasted from your favourite text-editing app. That was easy. Now I wonder: Are there any other “AppleScripts” I should know about? Like usual, let me know on Twitter or via email. Thank you for reading.