Jump to content

How to make a script filter accept any input


Recommended Posts

Following situation:

 

  • I have written a bash script to provide me a list of text suggestions
  • Each text has an abbreviation
  • When typing the abbreviation, I want the script filter to suggest the full text (basically setting the suggestion's autocomplete to "${query}${suggestion}")
  • This way, I can build a sentence quickly, from multiple text suggestions

 

My problem is, that when I type text for which there is no suggestion, and I press enter, the workflow step sends an empty string to the next step because it thinks my selection is empty. How can I make the script filter use the entire input field content as output, if no suggestion was selected?

 

I have multiple problems

  1. I know I can make the text itself into a suggestion, but that is slow (the script has to run each time)
  2. I have to run the script each time anyway, since I need to set "${query}${suggestion}" as autocomplete, or otherwise it will replace the entire content of the input field
  3. Can I make the script filter pass the entire input field value, if no selection matches or my typing is too fast for the script to finish?
  4. I would even prefer a solution with "Alfred filters results"

 

Thanks!

 

 

Edited by xanimus
Link to comment

Welcome @xanimus,

 

This is sounding like an XY problem. Can you give real example uses of the Workflow? Why not instead use Snippets or a List Filter Input connected to a Copy to Clipboard Output?

 

Maybe what you want is to use a Keyword Input with the same keyword as your Script Filter, so that when the latter doesn’t have results, you’ll act on the former. Or setup a Fallback Search Triggers. See a previous post for more information (replace File Filter with Script Filter).

Link to comment

I worked around it by having two hotkeys. One that takes random input, and one for the script filter with 'Alfred filters results'.

 

Is there a way I can set one item to always match (i.e. match any query) and always use the query as title/arg (all this when using 'Alfred filters results')?

Edited by xanimus
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...