Jump to content

How do I manipulate text in OSX selection before passing to google search


Recommended Posts

This is my first attempt at writing a workflow. Not sure where I could get more information about this.

 

So, I created a new workflow with a Hotkey as the trigger.

 

It will pass the argument to workflow and has the Selection in OSX as the argument.

 

I want to be able to manipulate this argument (specifically just to add a suffix, I know prefix is right there staring at my face) before passing it to the Google search workflow.

 

I want to know if its possible to do more complex manipulations (maybe through the use of bash/python/php scripts) other than prepending and appending text.

 

How do I go about it?

 

Thanks.

Link to comment

You take your hotkey block to pass the current selection, pass this into a script block for manipulating the text (I prefer PHP), then pass that to an "Open URL" block. If you just want to attach the text with a pre- or post- fix set of text, just go directly to the "Open URL" and put the text you want in there. Place the placeholder text {query} anywhere you want your selection to be placed. Therefore, you can put the following into the "Open URL" block:

 

http://mywebsite.com/{query}/pictures

 

The selection will replace the {query} text.

 

Richard

Link to comment

This is my first attempt at writing a workflow. Not sure where I could get more information about this.

 

So, I created a new workflow with a Hotkey as the trigger.

 

It will pass the argument to workflow and has the Selection in OSX as the argument.

 

I want to be able to manipulate this argument (specifically just to add a suffix, I know prefix is right there staring at my face) before passing it to the Google search workflow.

 

I want to know if its possible to do more complex manipulations (maybe through the use of bash/python/php scripts) other than prepending and appending text.

 

How do I go about it?

 

Thanks.

 

 

You take your hotkey block to pass the current selection, pass this into a script block for manipulating the text (I prefer PHP), then pass that to an "Open URL" block. If you just want to attach the text with a pre- or post- fix set of text, just go directly to the "Open URL" and put the text you want in there. Place the placeholder text {query} anywhere you want your selection to be placed. Therefore, you can put the following into the "Open URL" block:

 

http://mywebsite.com/{query}/pictures

 

The selection will replace the {query} text.

 

Richard

 

Not sure an "Open URL" was what he was looking for. I think they were more wanting to manipulate text and send it to another workflow (the Google Search workflow) to get suggestions within Alfred. Am I correct?

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