Run SearchLink with snippet

I was able to dig into Brett’s Instant Search script for SearchLink and create an extension that copies much of the functionality. Instead of opening the url, I just add it to the clipboard and paste using Launchbar’s after param.

# popclip SearchLink
name: SearchLink
icon: search s
applescript: do shell script "automator -r -i \"{popclip text}\" ~/Library/Services/SearchLink.workflow|awk '/http/{gsub(/^[ \t]*\"|\"[ \t]*$/,\"\"); print}'|pbcopy"
after: paste
1 Like

Wow amazing, after installing SearchLink.workflow to ~/System/Library I got it up and running. Quite a handy workflow and having it in PopClip is a bit magic.

I noticed it was only searching the first word of the selection - needs the input quoting like this \"{popclip text}\" (I’ve edited your source)

Thanks for the update… I was struggling to get the shell script to work (awk is awkward)…

1 Like

I wanted to include these in the original but I took too long and can’t edit. I’ll have a video on this soon but I wanted again to share here first. Here are the three Searchlink PopClip snippets (You still need search link installed)…

# popclip SearchLink + Multi Actions
name: SearchLink Copy
requirements: [text]
icon: search c
applescript: do shell script "automator -r -i \"{popclip text}\" ~/Library/Services/SearchLink.workflow|awk '/http/{gsub(/^[ \t]*\"|\"[ \t]*$/,\"\"); print}'|pbcopy"
# popclip SearchLink on Selected Text and Paste
name: SearchLink Paste
requirements: [text, paste]
icon: search p
applescript: do shell script "automator -r -i \"{popclip text}\" ~/Library/Services/SearchLink.workflow|awk '/http/{gsub(/^[ \t]*\"|\"[ \t]*$/,\"\"); print}'|pbcopy"
after: paste
# popclip Seachlink Open Selected Text in default browser
name: Searchlink Open
requirements: [text]
icon: search o
applescript: do shell script "open $(automator -r -i \"{popclip text}\" ~/Library/Services/SearchLink.workflow | grep -o 'https[^ ]*')"

Copy Runs Searchlink and adds to clipboard to be pasted elsewhere

Paste Is the same as the first but will replace the selected text with the results (good for overwriting in a blog post) - The original concept

Open Will open the results of the searchlink wherever. (Basically I’m feeling lucky)

1 Like

Okay final update unless I can simplify that awk which if You can think of a better way then here is the gist.

But I was able to get all three of the actions into a single snippet.

1 Like