Jump to content

Link to Markdown


Recommended Posts

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:

 

1845640409_Screenshot2018-11-1813_33_12.thumb.png.044000cd1c2345d747d52d716ad5690d.png

 

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 by cdpath
update download link
Link to comment

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:

image.thumb.png.0c0f33b13bb6f0ace26a819e51ec63ba.png

 

 

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 by cdpath
append
Link to comment
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.

Link to comment
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 by cdpath
fix typo
Link to comment
2 hours ago, Vero said:

 

Make sure you've checked the "Automatically paste to front most app"

 

clipboard-output-example.png

 

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)).)*$

Link to comment

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.

 

image.thumb.png.a50ffbbd0829a07eb705b86aa170e6f0.png

 

Yet still cannot figure out why branch 2 and branch 3 together can ACTUALLY works...

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