Create Auto-Expanding Rich Text Snippets with Workflows
Alfred includes a brilliant range of features, between the free version and the Powerpack. To help you discover (or re-discover) them, we've created this collection of tips and tricks.
Have you ever wanted to create rich text snippets in Alfred?
With a workflow, you can create snippets which includes formatted text and links. (You can do much more with Snippet Triggers, but let's start with something simple!)
Download the example snippet here to follow along this quick and easy tutorial.
The workflow consists of three objects:
1. Snippet Trigger object
Choose your keyword and set it in this object, as snippet keywords are stripped when importing a workflow to ensure it doesn't clash with keywords you've already set.
Double-click the object to open it and enter your keyword; Note that it'll then be prefixed by the "Shared Prefix" set below.
Take a look at our Tips for Better Snippet Expansion if you need a hand choosing suitable snippet keywords.
2. Run Script object
The next object is a Run Script action. This contains a very simple script which copies the content of the snippet1.rtf file (which is stored in the workflow folder) to the clipboard.
Edit the content of the RTF file by right-clicking the workflow name in the sidebar and choosing "Open in Finder", which opens the workflow folder. Open the RTF file in TextEdit and make the snippet look exactly as you wish. Save your RTF file and you're all set!
3. Dispatch Key Combo
Finally, our third object outputs the copied clipboard content to the frontmost app by performing a Cmd + V paste.
You're all done; In a rich text environment, use your snippet keyword and it'll be replaced by your new rich text snippet!
You can then duplicate the workflow as many times as you need to create other rich text snippets, by right-clicking the workflow in the sidebar and choosing "Duplicate".
Being able to harness the power of workflows directly from a text snippet gives you immense flexibility. Let us know on Twitter how you use Snippet Triggers.
Don't forget to take a look at past tips & tricks for more Alfred features you may not have discovered yet!