Jump to content
Ovi

Edit clipboard before pasting

Recommended Posts

@manavortex @Ovi What kind of modification do you have in mind when wanting to change text in the item you've copied to clipboard?

 

To be clear, we have no intention of adding a text editor to Alfred to edit arbitrary text before pasting, but there may be some clever ways you can do what you want with a workflow or snippet.

 

For example, if you have text that you want to paste with a few repeated changes every time (e.g. change someone's name, the price of something, etc), that could be achieved using a dynamic placeholder in a snippet. It's a much more efficient way and predictable way to paste something with specific elements changed every time.

 

If that's what you have in mind, take a look at the built-in workflow Getting Started > Snippet Triggers to see them in action. You'll also find a tutorial on using Snippet Triggers with dynamic content here:

https://www.alfredapp.com/help/workflows/triggers/snippet/snippet-triggers-with-dynamic-inputs/

 

If you have something else in mind, do share, as there may very well be ways to do it already :)

 

Cheers,
Vero

 

 

Share this post


Link to post
Share on other sites

Hey, 

 

my main use case is copying URLs from Safari and removing the referrers via regex. Currently I'm doing it via keyboard maestro, my regex (for now) is 
 

((\??(ref|src|fb[a-z]{4,}|utm_source)=.+))(.*)

 

If I have an URL like 

https://www.boredpanda.com/funny-internet-comics/?utm_source=facebook&utm_medium=social&utm_campaign=BPFacebook& 

that basically leaves

https://www.boredpanda.com/funny-internet-comics/ 

 

Since Alfred already has a builtin clipboard manager, it would be my tool of choice. 

 

What I'd like would be one of the following: 

  • Trigger an Alfred workflow on external clipboard change (to avoid endless recursion)
    • Advantage: Greater flexibility
    • Disadvantage: Another kind of trigger that you might not want to replace
  • A feature to the Alfred clipboard manager to replace clipboard content based on rules
    • Advantage: More foolproof
    • Disadvantage: Would probably require major changes..? 

Please let me know how I can achieve that with built-in means! 

Edited by manavortex
wrong syntax highlighting

Share this post


Link to post
Share on other sites

Not a complete solution, but this establishes a hotkey that takes highlighted text in Safari, runs it through your regex, then sends the result to the clipboard.  Here, I've elected to use 〈Ctrl〉+〈C〉 as a close relative of 〈Cmd〉+〈C〉.

 

image.thumb.jpeg.1b8dcd608001b589b5fa135fbb50c180.jpeg

Share this post


Link to post
Share on other sites

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

×