Using Clipboard History Items In Workflows and Snippets

You can use the {clipboard:x} placeholder to obtain items from Alfred's clipboard history to use within your workflows and snippets.

In this guide:

What are clipboard placeholders?

If you're not familiar with them, dynamic placeholders are short keywords wrapped in curly brackets, which can be used to indicate to Alfred what you want the keyword to be replaced with.

These include date and time, as well as the clipboard contents, so take a look at the full list of dynamic placeholders, and can be used in

Snippet with 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, and format the text before pasting.

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.


Built-in Examples using Clipboard content

Take a look at the new "Clipboard" workflow under the Getting Started built-in workflows (in Alfred 3.3+) to see how the clipboard history placeholder can be used:

  • With a hotkey to paste the clipboard contents as plain text;
  • Using a keyword to create a text file to the Desktop, adding the latest 3 clipboard items to it, then opening the file;
  • Merging the latest clipboard items into one text clip and pasting to the frontmost app;
  • Setting clipboard items as workflow variables.

image

Double-click each object to see how the clipboard is used in that particular scenario.


Ideas for your own Clipboard workflows

With so much flexibility, you can use Alfred's clipboard content in a wide variety of contexts.

Set a hotkey to paste the second clipboard item

This simple hotkey-based workflow pastes the second item in your clipboard as plain text to the frontmost application.

First, create a new workflow, and add a Hotkey trigger connected to a Copy to Clipboard output. Set a hotkey in the first object, leaving Action and Argument to defaults.

Workflow to paste the 2nd clip

Double-click the Copy to Clipboard object to configure it as follows:

Configuring the Copy to Clipboard object

Now, when you use your hotkey, you'll paste the second item from your clipboard history. Marking the item as transient means that it won't be brought back to the top of the clipboard history list.

You could then create another hotkey and Copy to Clipboard chain to paste the third item, if you fancy! :)

Create a log file with the date and latest clipboard item

In this example, we create a log file containing the current date and latest clipboard contents.

Add a keyword input and a Write Text File output. Set a keyword and change the argument dropdown to "No argument".

image

Double-click the Write Text File object to configure it:

  • Set the File name and path;
  • If the file exists, we want the workflow to append to the log;
  • The content will consist of a dynamic placeholder for the current date, followed by the clipboard content.

image

Typing "log" will now create a file (the first time), and add the date and clipboard text.

With these examples, you can now go on to create your own workflows involving clipboard history items!

Latest Blog Post:

Alfred 4.6.5 Released: 1Password 8 Workflow Integration

CacheFly Campaign Monitor

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

Terms & Conditions, Privacy Policy, Cookies.