Introducing Extension Snippets

PopClip 2021.11 introduces a new, simple way to create and share your own extensions, which I am calling Extension Snippets.

It is easiest to show with examples, so without further ado, here is an extension snippet:

# popclip
name: Emojipedia
url: https://emojipedia.org/search/?q=***

Select that text above, and you’ll see an “Install Extension” action in PopClip:

CleanShot 2021-11-16 at 17.51.09

Wait, what just happened?!:exploding_head:

You installed a new extension in PopClip just by selecting some text! This particular extension will search Emojipedia for the selected text.

Hopefully you are starting to realise the possibilities. You can now create your own extensions just by typing text in a text field and selecting it. You can do it anywhere you can type text — in the TextEdit app, in your favourite notes app, anywhere you like.

For example, you can go ahead and change the name and the URL from the example above to anything you like, to create your own search extension (keeping the *** as the search query placeholder).

Extension snippets are also easy to share with others, since you can put them anywhere you can put text.

NOTE: When typing a snippet in this forum, you’ll need to format it as Preformatted Text (using the toolbar button, or use three backticks on the lines before and after)

I need to know more 🧑‍🏫

The format of an extension snippet is actually the same as for a regular extension — which is all documented in detail here.

A snippet must start with the first line # popclip (with or without the space) and must be no more than 1000 characters.

The snippet uses a format called YAML to define the extension’s properties such as its name, icon, and to define its action. If that sounds complicated, don’t worry. Usually you can just copy one of the examples and edit it.

Snippets can be used for all types of PopClip extension, except Shell Script extensions. So you can use snippets to open URLs, run Shortcuts, call Services, press keys, run AppleScripts, and run JavaScript code.

Adding an icon 🧑‍🎨

Let’s go back to the Emojipedia example. Let’s say we want to give it an icon. We can do this as follows:

# popclip
name: Emojipedia
icon: search filled E
url: https://emojipedia.org/search/?q=***

You’ll see I added the line icon: search filled E. This gives the action a magnifying glass icon with an E in it:

Instead of a magnifying glass you can put it in a circle or a square, filled or not filled. And using symbol:<symbol name> you can use macOS’s built in SF Symbols icons. Here are some examples:

Next steps :foot:

Rather than make this post really long, I’m going to be posting in this forum some “How To” guides with examples of various types of extension (see below).

I’ve also created a new forum category - Show and Tell - where people can post their own snippets that might be of use to others.

Hopefully that has whet your appetite for the possibilities of Extension Snippets. Stay tuned for more to come.

Guides

11 Likes

Love it! It’s kind of surprising how easy it is isn’t it :slight_smile: Really happy you were able to put it together. My aim with this has been to distill the extensions down to their simplest form without all the XML files and identifiers and extra gubbins that used to be needed, so that more people can create their own extensions.

p.s. I took the liberty of editing your opening backticks as ```yaml to make the syntax highlighting nice. An alternative is ```text to get all one colour.

edit: I’ve now set ```text as the default on the forum.

2 Likes

This is wonderful, great work!!

1 Like

Bugger. I accidentally deleted my previous post when I was trying to copy it to share in the new subforum. Please find it here: Remove Dots

1 Like

I have magic powers :sparkles:

Hi Nick,

Great Feature ! I’ll replace my own snippets with this system (and delete PopMaker ! :wink: )
But I have a question about the icon. Before we put them in the package but with feature ? if they are on my local hard disk, for example ?
Thank you in advance
Ange

Hi Ange, one of the limitations of snippets is that icons can only be specified using the text format or as SF symbols. You can’t refer to files on disk.

If you wanted to use your own icon file you would have to convert the snippet into a packaged extension.

The steps to do that:

  1. Create a new text file called Config.yaml and paste the contents of the snippet (you could do this in TextEdit in plain text mode or any plain text editor)
  2. Enclose the Config.yaml in a folder named like ExtensionName.popclipext

You can then add an icon file to the package and change the icon: field in Config.yaml to be the icon file name.

Thank you for the explanation, but I probably do a mistake : it doesn’t run ! I obtain the following error :
Monosnap 2021-12-28 14-42-44

The content of the package named Allocine3.popclipext is:
Allocine3.popclipext 2021-12-28 14-44-13

And the content of the Config.yaml file is:

# popclip
name: Allocine3
icon: AllocineIcone.png
url: https://www.allocine.fr/rechercher/?q=***

Where is my error ? Thank you in advance !
Ange

It looks fine from what you have posted. Can you email me (support@pilotmoon.com) a zip of the extension itself, I can take a proper look.

Ok, sent.
Thank you !

1 Like

This is an incredible well-crafted feature.

1 Like