cdpath Posted November 18, 2018 Posted November 18, 2018 (edited) Why I need this? Sometimes I just found myself repeating copy/paste URL and title from Chrome to write some reference. Even worse, different apps accept different format (Yeah, I'm talking about you, Ulysses!). So here is my workflow: Usage Just type \\u in your favorite app. Problem 1. I tried and failed to use matches regex in Filter Utility, that's why I have to hard coded three (and maybe more in the future) filter. This is my failed attempt: Notes|Evernote|scapple 2. The else (marked in red in screenshot above) is not actually fallback, which may lead to some bug. # What I thought it would be if condition_a: ... elif condition_b: ... elif condition_c: ... # How it actually works if condition_a: ... if condition_b: ... if condition_c: ... Download https://github.com/cdpath/alfred_workflows/releases/tag/0.1.1 Edited November 20, 2018 by cdpath update download link vitor 1
cdpath Posted November 18, 2018 Author Posted November 18, 2018 (edited) I did some experiment. Here is what I found: Problem 1 The regex Notes|Evernote|scapple actually works fine Problem 2 I found Regular Expression to exclude a list of words and figured out the following regex to mimic fallback else ^((?!(ulysses|Notes|Evernote|scapple)).)*$ So I got this: And something fancy happened. The second branch (Notes|Evernote|scapple) doesn't work anymore. It seems Copy to Clipboard failed to paste the incoming content. I have to use Key Combo to fix it. I highly doubt it has something to do with the performance of regex in else branch: ^((?!(ulysses|Notes|Evernote|scapple)).)*$ . If I replace it with ^((?!(ulysses)).)*$ , everything works fine. Edited November 18, 2018 by cdpath append
deanishe Posted November 18, 2018 Posted November 18, 2018 32 minutes ago, cdpath said: It seems Copy to Clipboard failed to paste the incoming content. I have to use Key Combo to fix it The Key Combo should come after the Copy to Clipboard, not be alongside it. The way you have them set up, Alfred will run them simultaneously, and it's just luck that the clipboard is set before the key combo is triggered.
cdpath Posted November 18, 2018 Author Posted November 18, 2018 (edited) 29 minutes ago, deanishe said: The Key Combo should come after the Copy to Clipboard, not be alongside it. The way you have them set up, Alfred will run them simultaneously, and it's just luck that the clipboard is set before the key combo is triggered. I got your point. I simply put Key Combo alongside Copy to Clipboard to give some illustration (misleading, though 😂). Without the Key Combo, the Copy to Clipboard alone still didn't work. Here is the updated workflow: https://github.com/cdpath/alfred_workflows/releases/tag/0.0.7 Edited November 18, 2018 by cdpath fix typo
deanishe Posted November 18, 2018 Posted November 18, 2018 5 hours ago, cdpath said: the Copy to Clipboard alone still didn't work That really shouldn't happen. I believe Alfred itself triggers the paste event in exactly the same way as the Key Combo does.
Vero Posted November 19, 2018 Posted November 19, 2018 18 hours ago, cdpath said: the Copy to Clipboard alone still didn't work. Make sure you've checked the "Automatically paste to front most app" Cheers, Vero
cdpath Posted November 19, 2018 Author Posted November 19, 2018 2 hours ago, Vero said: Make sure you've checked the "Automatically paste to front most app" Cheers, Vero Yeah, I checked both Automatically paste to front most app and Mark item as transient in clipboard The wired thing is, with anything else unchanged, the regex in else (the filter utility) can affect the behavior of the second branch (the one with Notes, Evernote, scapple). regex cause problem: ^((?!(ulysses|Notes|Evernote|scapple)).)*$ regex that works fine: ^((?!(ulysses)).)*$
cdpath Posted November 19, 2018 Author Posted November 19, 2018 Found the bug finally. In the purple Run Script below, I actually passed nothing to the next action (only send content in pbcopy) , which means the following Copy to Clipboard has nothing to do. Meanwhile, with regex ^((?!(ulysses)).)*$, the third branch is selected too. Yet still cannot figure out why branch 2 and branch 3 together can ACTUALLY works...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now