Jump to content

Snippets - inject text from a URL?


Recommended Posts

I am currently using Espanso for snippets, in spite of owning and using Alfred for about ten years now, because my use of Alfred is only just scratching the surface.

 

Snippets. What you can do with Espanso is you can say... "I currently have :SUB: subscribers", and then define :SUB: as the results of opening https://example.com/subscriber-count. That itself returns "18,456", and so the snippet is filled-out as "I currently have 18,456 subscribers".

 

Is that sort of thing possible in Alfred, using Snippets or something else?

Link to comment
54 minutes ago, jamescridland said:

Is that sort of thing possible in Alfred, using Snippets or something else?

 

Yes, that's fairly simple to do with Alfred. Just a Run Script action with Language = /bin/zsh:

 

# fetch contents of URL and save them to variable "count"
count="$( curl -fsSL http://domain.com/path/to/page )"
# output to next action
echo -n "I currently have $count subscribers"

 

Connect that to a Copy to Clipboard output with "Automatically paste to front most app" selected.

 

You can trigger it via a Keyword, Hotkey or Snippet Trigger.

Link to comment

Oh, that's awesome, thank you.

 

Just pointing me in the right direction to get started was really helpful - I didn't have much idea what to do here. I must get to use Alfred more, I bet it'll do rather more than just open programs (which is all I'm really using it for up to this point).

 

Now I have a nice snippet writer. Yay! :)

Screen Shot 2021-05-15 at 5.22.19 pm.png

Link to comment

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...