Jump to content

Trim whitespace with 'web search'


Recommended Posts

I have a workflow to invoke alfred with selected text. I usually use the selected text with my web search keywords to open specific pages. One annoyance is that the selected text can contain white space at either end.

 

e.g. typing "imdb<space><space>godfather" in the alfred window search IMDB for "<space>godfather". 

 

 

This is not a problem with IMDB but it is with the web applications I use everyday. Please consider adding an option to trim leading/trailing white space when used with web search.

 

Link to comment

I currently use the single step workflow, created using Add Workflow (+) -> Templates -> Show Alfred -> Show Alfred with selected text. My changes to this was to change cursor position to 'left' and a custom hotkey. Based on your suggestion, I modified the action in it from "Show Alfred" to "Pass through to workflow". Indeed I was able to add a Trim Whitespace as the next step. However, for step 3, I can't add a "Show Alfred". Closest is "Browse in Alfred" which is not useful in this context. I'm probably missing the obvious, how can I get a "show alfred" as the last step with the selected text?

Link to comment

Thanks, I built on that suggestion (replaced {query} with q) and can Alfred to show with the trimmed selection. However I would like the cursor to reach the front of the text with a leading space so I can simply type my web shortcut keyword. Here's what I have. The commented lines don't work (123 is keyboard left, 49 is space bar)

 

on alfred_script(q)
  tell application "Alfred 3"
    search q
    activate
--  keycode 123 using command down
--  keycode 49
--  keycode 123 using command down
  end tell
end alfred_script

 

Link to comment
10 hours ago, Gautam said:

I did try to run a script (type osa) as well but doesn't accomplish what I want. I'll give up on this for now, thanks for your assistance.

 

 @deanishe  I'll give your Alfred Workflow library a try later.

 

If you upload the non-working workflow and post a link to it, we can help you fix it.

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