Jump to content

GIF Search: Workflow for Searching and Browsing GIFs

Recommended Posts

Alfred GIF Search

Download: Gif.Search.alfredworkflow

Up-to-date README (this post is outdated)

This workflow lets you search GIFs on Tenor from Alfred.

Here's an example of searching and inserting a GIF in a google doc:


  1. Download the latest release.
  2. In Alfred, run .setup-gif-search.


  • In Alfred, enter gif keyword followed by search query.
  • Press .
  • Use arrow keys or mouse to browse the GIFs.
  • To copy the selected GIF to clipboard:
    • either ⌘↩
    • or ⌘-click
  • To drop the GIF into apps that support it:
    • drag from Alfred and drop into that app


Firefox and Chrome don't support pasting GIFs from clipboard. That is, if you copy a GIF to clipboard and paste it, it shows up as a static image, not an animated GIF. This is not a bug in this workflow, but rather just the way these browsers have decided to handle GIFs.

Both Chrome and Firefox support drag-n-drop. If you use either of these browsers, sorry, you gotta use the mouse!

Edited by Mr Pennyworth
Link to post
  • Mr Pennyworth changed the title to GIF Search: Workflow for Searching and Browsing GIFs

This is super cool @Mr Pennyworth! I love how you're using the secondary panel to augment the Alfred results... I kind of wish this were a feature built-in to Alfred itself... What is the process for building this kind of thing? 


I did find your alfred-extra-pane repo and I assume I would use that to build this functionality into my own workflows?

Link to post

Thanks @chris! When you want a panel to be shown at side, and some HTML to be show inside it, yep, you can use the AlfredExtraPane.app. All you got to do is add an html filepath to quicklookurl of the JSON and then pipe it to the app (the readme has an example).

For building something like this GIF workflow, it is true that AlfredExtraPane.app was an inspiration, but it can't just directly be used to build the GIF workflow, it isn't flexible enough. For this GIF workflow, I simply took the code of AlfredExtraPane.app and modified it to fit the GIF needs, thus programming in swift was involved and understanding how AlfredExtraPane.app works internally was a prerequisite.

Link to post


I've put together a small tutorial for workflow authors here:



And a few question-answer pairs for technical internals here:



I see a few problems with swiftUI:

  • I would imagine there are far more workflow authors who can put together nice looking HTML than swiftUI, all the complexities of the implementation of the extra pane aside, as far as the workflow authors are concerned, I want the integration to be as simple and friction-less as possible. HTML seemed like the best choice for that.
  • I'm not sure how code for compiled language will actually work for the previews. Let's say instead of putting an html file in "quicklookurl", we ask the workflow authors to put a swift file instead. Who compiles the code? Can swift code be even compiled on-the-fly by an app and rendered too? I haven't a clue! :)
Edited by Mr Pennyworth
Link to post

This is a pretty neat workflow, @Mr Pennyworth! I love the execution, but I ran into a few issues on different versions of the workflow:


I initially installed v0.0.3, but the workflow exited whenever I used the arrow keys to navigate the GIFs, and clicking and dragging the GIF had no effect.


I decided to try v0.0.1, which took care of the above issues. However, after trying out the drag-and-drop feature, the Tenor link (and related GIF) kept appearing whenever I tried to paste any new text that I'd just copied. This issue persisted even after using Terminal to refresh the Clipboard, and I had to restart my computer in order to regain control of the Clipboard.


You may have already addressed this in v0.0.3, but in any case just thought it was worth pointing out. Thanks, and look forward to seeing what you come up with next!

Link to post

@dood whoa! that sounds like such an ordeal and so much trouble


I wish I could help, but I'm not able to replicate the issue :(

Here's what I did:

  1. Downloaded and ran v0.0.3, worked as expected
  2. Created another user account on my macbook (so alfred gets to have a clean slate), then repeated (1), again worked as expected
  3. Installed Alfred on a spare macbook I have, then repeated (1), couldn't trigger the bug

At this point, I don't have much to go on...

Are you on macOS other than Catalina? I have no means of testing on versions other than Catalina
Does AfredGifBrowser.app have the required accessibility permissions? Does deleting it from accessibility permissions and adding again help?

Link to post

Thanks for looking into it, @Mr Pennyworth! I'm on Catalina, and observed the same behavior in v0.0.3 even after deleting and re-adding the accessibility permissions.


Would it be helpful for me to send debug logs, etc.? Also don't want to take up too much of your time if this appears to be an isolated issue.

Link to post

@dood yep, it'll definitely be helpful!

In addition to the in-Alfred debug log, also useful would be the debug logs for 'AlfredGifBrowser'.
Here's how to collect it:

  • Run `killall AlfredGifBrowser` in terminal
  • Open the workflow folder in terminal
  • Run `AlfredGifBrowser.app/.Contents/MacOS/AlfredGifBrowser` (this will make the logs appear right in the terminal)
  • Run the workflow v0.0.3 and press the arrow keys so that it crashes
Link to post

I've run into an issue with the Clipboard History Viewer.


If I hit Return on an item in the viewer, the item is pasted into the foreground app as expected. However, if I Command-C an item in the viewer (to avoid pasting it), rather than copying the item back to the clipboard, it copies "/Users/<username>/Library/Caches/com.runningwithcrayons.Alfred/Workflow Data/mr.pennyworth.gif/selected.gif"


Disabling the workflow has no effect, but killall AlfredGifBrowser restores the expected behavior until I run the workflow again.

Link to post

@evanfuchs sorry, I'm confused...

Can you give me a step-by-step detailed explanation of what you expect to happen and what actually happens?


From your description, it seems like it is working correctly...
you hit ⌘C, then go about doing something
then, when you want to paste the GIF, you hit ⌘V
the gif should be pasted. Is it not being pasted?


BTW, the workflow doesn't put image data onto the clipboard, it simply puts a file onto the clipboard.
That's the file you are seeing in clipboard viewer.


14 minutes ago, evanfuchs said:

but killall AlfredGifBrowser restores the expected behavior until

Can you elaborate what the expected behavior is?

Link to post
5 minutes ago, Mr Pennyworth said:

Can you give me a step-by-step detailed explanation of what you expect to happen and what actually happens?


Sure, sorry about that. The workflow is working as expected, but I am finding an unexpected issue the Clipboard History Viewer related to the workflow.


The typical behavior after triggering the Clipboard History Viewer (for example, using the keyword clipboard), is that RETURN will paste the selected item into the foreground app, while COMMAND-C will copy that item back to the clipboard so you can paste it elsewhere without automatically pasting into the foreground app.


After installing and running this workflow, COMMAND-C puts /Users/<username>/Library/Caches/com.runningwithcrayons.Alfred/Workflow Data/mr.pennyworth.gif/selected.gif on the clipboard.


If I run killall AlfredGifBrowser, the issue with Clipboard History Viewer goes away.


I hope I'm explaining it clearly.



Link to post
13 minutes ago, Mr Pennyworth said:

@evanfuchs aha! got it!
That's such a bad bug!!
Thanks so much for reporting it :)

I fixed it in v0.0.5, download it and give it a go :)


Thanks for the quick fix!


FYI: I first installed v.0.0.5 allowing it to update the previous version and that did not work. I uninstalled it, killed AlfredGifBrowser, installed again and it's good to go. In case that helps anyone else trying to update.

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...