Using Dynamic Placeholders

Alfred offers dynamic snippets, which allow you to insert dynamic content into a snippet when using Clipboard Snippets and in certain workflow objects.

The workflow objects where dynamic content can be used are the Copy to Clipboard, Large Type and Write Text File outputs.

What is Dynamic Content?

When creating a snippet, or setting the output of a workflow, you'll most likely include some fixed, pre-defined text.

In other instances, you may want to add today's date, or the contents of your clipboard; This is dynamic content, as it can change every time the snippet is pasted.

In this example, various keywords in curly brackets are used to paste dynamic content amongst the pre-defined snippet text.

Example of a text snippet with dynamic content

You can add the following types of data dynamically:

Using Dynamic Content

Date and Time

To use a dynamic date or time, begin with date or time. You can follow this with optional default formats (short, medium, long, full).

For example, {date} will paste the current date in the default format, while {date:long} will give me the date in the long format.

The {date} and {time} placeholders use your macOS default formats. You can change these in your Mac's System Preferences > Language & Region > Advanced settings under Date and Time.

Setting your Date and Time preferences

You can use the Unicode LDML formats for dates to be more specific with your date formatting.

Unicode LDML Date Format Patterns (Advanced)

  • ISO 8601 date format: {date:yyyy-MM-dd'T'HH:mm:ssZZZZZ}
  • Day/Month/Year: {date:dd/MM/yy}
  • 12-hr clock with time zone: {date:K:mm a, z}

Cursor Placement

Use {cursor} to position the cursor somewhere other than the end of the pasted text.

Note that there are limitations to the cursor placement; Certain apps may not allow you to re-position the cursor beyond the beginning of the current line.

Clipboard contents

Use {clipboard} by itself to paste the content of your latest clipboard entry as plain text. You can also specify which clipboard item to use by using the clipboard offset, and perform some basic formatting (uppercase, lowercase and capitals).

Using clipboard offset to paste previous clipboard items

The clipboard offset allows you to specify which clipboard items you want Alfred to paste.

{clipboard} and {clipboard:0} represent the latest item in your clipboard; these may differ if your workflow manipulates the clipboard content.

For the next items in the clipboard list, use {clipboard:1}, {clipboard:2}, and so on.

Note: Clipboard History must be enabled on your Mac in order for {clipboard:x} items to be available.

An example of clipboard offset usage

For example, if you copy these three text items to your clipboard:

First item copied: Andrew
Second: hedgehogs

And then create a snippet or workflow output as follows:

Hi {clipboard:2}, thanks for your question about {clipboard:1}. You can find your answer here: {clipboard:0}.

Resulting in:

Hi Andrew, thanks for your question about hedgehogs. You can find your answer here:

Order of operations for replacement in the clipboard

For more advanced workflows, keep in mind the order of replacement for dynamic placeholders:

  1. Variable replacements
  2. {query} replacement
  3. Snippet style replacements (date, time)

The top level workflow environment variables are treated as literal, but may be processed as they're encountered in processing the workflow.

Formatting the clipboard contents before pasting

The Clipboard placeholders allow you to quickly format the text as follows:

  • {clipboard}
  • {clipboard:uppercase}
  • {clipboard:lowercase}
  • {clipboard:capitals}

Including Workflow Variables

You can also substitute upstream variables into the output by using {var:varname}. This dynamic placeholder can be used in the Copy to Clipboard, Large Type and Write Text File outputs.

Find out more about using Variables in workflows.

Need to transform your clipboard content in a more complex way? Take a look at the Workflows' Transform Utility object, which allows you to manipulate text content in more ways.

Latest Blog Post:

Perform File Actions Easily from Alfred or Finder

CacheFly Campaign Monitor

"Alfred" is a registered trademark of Running with Crayons Ltd. ©2017 Running with Crayons Ltd. All rights reserved.

Terms & Conditions, Privacy Policy, Cookies.