July 22, 2018

Create global Quip shortcuts using Alfred and AppleScript

I often need to search Quip or create a new document really quickly. Here’s how to use Alfred to create global keyboard shortcuts:

^N = Create a new blank Quip document in my Private folder
^/ = Jump to Quip’s search bar

(Note, this requires the Alfred Powerpack and the Quip desktop app for Mac to be installed.)

It’s not perfect (e.g. the shortcut keystrokes might get dropped if Quip isn’t already open), but it suits my workflow where Quip is always running and I just need to quickly jump to it. This would be much easier if Quip supported AppleScript natively!

Shortcut to create a new blank Quip document

In Alfred Preferences, go to the Workflows tab then click the plus in the bottom left to create a new Blank Workflow”. Name it Quip”.

After you’ve created the workflow, right click the workflow area and choose Actions > Run NSAppleScript.

Use this script:

on alfred_script(q)
  set UP_ARROW to 126
  tell application "Quip" to activate
  tell application "System Events"
    keystroke "i" using {command down, shift down}
    keystroke "n" using {command down, option down}
    delay 1
    key code UP_ARROW
  end tell
end alfred_script

Add a hotkey trigger to the workflow area and feed it into your NSAppleScript action. I used ^N for mine.

You can also add other triggers, like a keyword in Alfred. (I have nqp, for new quip”, as an optional keyword to type in at the Alfred prompt.)

Test it out!

How it works

It works by activating the Quip application and then sending keyboard shortcuts to the app to create the new document. The I shortcut takes us to the Updates” page first, which ensures the new document will be added to your Private folder, rather than any folder you might have happened to already be in.

Finally, the up arrow we send at the end just puts the cursor in the title line, so we can name the document right away. We have to send this after a 1 second delay to let Quip load the document completely.

Follow the same process as before, but use this for your AppleScript:

on alfred_script(q)
  tell application "Quip" to activate
  tell application "System Events"
    keystroke "o" using {command down, option down}
  end tell
end alfred_script

The final product

The final workflow looks like this:

Quip workflow in Alfred


Alfred


Previous post
Network protocols you should care about as a software developer
Next post
How to write a simple Chrome extension to search Reddit for the article you’re reading