Jump to content

Funnel (a variant of the Pipe workflow)


Recommended Posts

Funnel takes text and converts it to some other text by running it through a filter. The filter can be a shell script one-liner or a full script. Anything that takes standard input and outputs to standard out. At the moment, the following filters are implemented:

 

- Base64 - decode
- Base64 - encode
- AES-256 - decrypt with passphrase 'X'
- AES-256 - encrypt with passphrase 'X'
- x509 - fingerprint
- x509 - hash
- x509 - certificate information
- Change case - lowercase
- Change case - uppercase
- Change case - capitalize
- Change case - title case
- JSON - format
- String - reverse
- String - format US phone number
- Lines - clear bullets
- Lines - sorted unique lines
- Lines - number lines
- Lines - bulletize
- Lines - top 10 unique lines
- Lines - remove blanks
- Lines - unique lines only
- Lines - doublespace
- Markdown - convert search links to normal links
- Markdown - convert to HTML
- URL - encode
- HTML - encode
- Sort IPv4 addresses

 

The Funnel workflow is a variant of the preexisting Pipe workflow (http://www.alfredforum.com/topic/1187-filter-clipboard-through-your-favourite-one-liners). I wasn't happy with how the workflow presented options and I didn't want the options sorted by Alfred. I also wanted to bundle some heavier processing scripts, so I created my own version of the workflow from scratch.

 

The workflow can operate on text on the clipboard, on a file whose filename is on the clipboard, on selected text (using a hotkey) or on a selected file (using a hotkey). No matter where the text comes from, it is piped through the selected filter. If the text came from the clipboard or a selection, it is pasted into the active application after being processed. If the text came from a file, the file contents are replaced with the processed text.

 

So, for example, if you select a block of text and trigger the workflow with a hotkey, you can choose 'Lines - bulletize' and the selected text will be replaced with bulleted lines. If you select a JSON file in Finder (or Path Finder) and trigger the file hotkey, you can choose 'JSON - format' and the file contents will be replaced with formatted JSON.

 

Update: As Vitor pointed out, I forgot the link :-) https://github.com/packal/repository/raw/master/com.tedwise.funnel/funnel.alfredworkflow

Edited by ctwise
Link to post
  • 1 month later...

Hmm, nothing's happening. What am I doing wrong? Tried the Markdown-HTML filter and the bulletize filter. Using both selected text and clipboard text. :(

 

On 10.9.2

 

If you're using the latest Alfred, can you turn on workflow debugging and see if you see any output?

Link to post

The "funnel" keyword script filter has the title "Funnel selected text through filter" but it seems to ignore selected text and use the clipboard contents instead.

 

You are correct. The only way in Alfred to act on selected text is through a hotkey. Otherwise the Alfred input box becomes the text source. I'll update the workflow.

Link to post

Knowing next to nothing about scripting, I managed to adapt the HTML encode one-liner into an HTML decode one-liner:

    "HTML - decode": "php -r \"echo html_entity_decode(file_get_contents('php://stdin'), ENT_COMPAT | ENT_HTML401, 'UTF-8');\"",
Link to post

 

Knowing next to nothing about scripting, I managed to adapt the HTML encode one-liner into an HTML decode one-liner:

    "HTML - decode": "php -r \"echo html_entity_decode(file_get_contents('php://stdin'), ENT_COMPAT | ENT_HTML401, 'UTF-8');\"",

 

Awesome! I added it to the workflow.

Link to post
  • 3 months later...

When I try it, it doesn't complete the filter names.

 

Debug output is as follows:

 

[ERROR: alfred.workflow.input.scriptfilter] Code 1: complete.rb:2:in `require': no such file to load -- json (LoadError)

from complete.rb:2

 

I can't actually see complete.rb anywhere in the workflow screen, and I don't know where Alfred stores workflows, so I can't debug this further myself.

 

This is on OS X 10.8.5, with Alfred 2.3 (264).

 

Does anybody have any ideas what's going wrong? Am I missing a gem?

 

Thanks

Link to post
  • 1 month later...
  • 3 years later...
9 hours ago, Beery said:

Is there an easy way to see all the filters (after typing "funnel")?

 

Insert 2 spaces after "|" or change the Script Filter node for the "|" keyword to "Argument Optional" (I think the second option would be best if you still want to filter the results normally)

Link to post
39 minutes ago, evanfuchs said:

Is there a way to eliminate the extra single line break when converting to lowercase, uppercase, and title case (doesn't happen with capitalize) and the extra two line breaks per bullet when using "clear bullets"?

 

Not without touching the code, but here I made it works for you. However, note that this would get reverted if you update to a newer @ctwise update if he don't make the change to his workflow.

 

In short, in "filters.json" change "perl -nle" to "perl -ne" for the "lowercase" and "uppercase" actions. Change line 79 (print $_, "\n";)  in the file "titlecase.pl" to  "print $_;" and line 37 ($line =~ s/^([ \t]*)(\d+\. |[\*\+\-] )?\s*(.*)/${1}${3}\n\n/;) in the file "bulletlist.pl" to "$line =~ s/^([ \t]*)(\d+\. |[\*\+\-] )?\s*(.*)/${1}${3}/;"

 

Download: https://nofile.io/f/B3kpSz6Pxom/Funnel.alfredworkflow

Edited by GuiB
Link to post

@evanfuchs, sorry for the delay, I needed to go... but I've found that you were maybe talking about the Capitalize action which I didn't modify before. I've found that it did what you said (it strips existing line breaks), so I fixed it (now using a simple python "capitalize()" function)

 

Here is the updated workflow: https://nofile.io/f/0j4Gjdxwoby/Funnel.alfredworkflow

 

Best!

Link to post
  • 2 years later...

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