Jump to content

Removing keywords in fallback searches?

Recommended Posts

Is it possible to remove a keyword that winds up being used in a fallback search?


Since I’m probably not asking this question in the appropriate Alfred lingo, let me provide an example.

  1. Let’s say you have a file filter that uses the keyword “oo” when searching for OmniOutliner files.
  2. After searching for “oo searchterm in Alfred, it doesn’t find anything relevant, and so you decide to use one of your fallback searches. 
  3. For simplicity, let’s say you select the default Google search fallback. 
  4. When run, Google searches for the following: “oo searchterm”. My question is whether it could be run without the “oo “ (i.e., without the keyword and space). In other words, could Alfred snip out everything before the first blank space in the search (and preferably the first blank space, too)?


To be clear, my question is not specific to Alfred’s default Google search fallback. I have other fallbacks that use Finder, Spotlight, etc that I’d like to solve the problem with. 


I just find it annoying to always have to go back and clip off that first bit, especially when the searches all follow the same pattern (unnecessarykeyword+blankspace).


Thanks for your help!

Link to comment

Since a fallback search can't determine what you have in mind when you give it a string to process, there's no way it could intelligently remove the first word of a string (well, from my understanding). Therefore, I think you best bet would be to redefine the fallback searches that you wish them to process how you define it.


I did a workflow as an example to show you as a way to make a more "intelligent" fallback search based on your criteria. I did two version, but I think the first one would be the best one to use as a replacement to the default fallback search, but need a little more work from your side. In short, you make a list of keywords separated by semicolon and if you send a string to this fallback search and the workflow find that the first word is into this keywords list, then it will remove it or if not found it would keep the string as is. The second example always remove the first word, so maybe best to use next to the default fallback search.


To change the keywords list or add to it for the first method, just look into the environment variable in the Workflow preferences. I put ";" as the delimiter, but let you change it if you prefer another one


Link: https://nofile.io/f/RX05s5Z9c8o/Fallback+Search+-+Removed+Keyword.alfredworkflow



Edited by GuiB
Link to comment

@Jasondm007, sorry, I don't know what happened, but here is another try at uploading:






Make sure to add the Fallback Search to you Default Results Fallback Searches at :

Alfred Preferences -> Default Results -> Setup fallback results -> + -> Workflow trigger -> Search Google for '{query}' (Removing keyword)   or   Search Google for '{query}' (Removing first word)

Edited by GuiB
Link to comment
  • 1 month later...
  • 4 months later...

@GuiB I'm not sure how I missed your response above (perhaps, the holiday fog?), but I recently stumbled on this thread when looking for a fix to the same problem.


In any event, I just wanted to apologize for the slow response and thank you for posting your workflow. It's brilliant, and works like a charm!

Link to comment
  • 1 year 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...