MACRO: Run SearchLink, Gather, Browser, v3.0


PURPOSE

After selecting* some text (in an editor or text field), this macro will display a dialog** which can be used to run one of five options:

  1. SearchLink
  2. Gather
  3. Browser
  4. SearchLink followed by Gather
  5. SearchLink followed by Browser

SearchLink, by Brett Terpstra, is a macOS System Service which searches the web to generate Markdown links. This macro runs a command line version of the System Service.

Gather, also by Brett Terpstra, is a command line application which converts webs URLs to Markdown text.

Browser is a shorthand term for the Keyboard Maestro macro Activate, Reload, or Open Browser Tab.

*If no text is selected, the macro will use the text stored in the System Clipboard.

**The dialog includes three options for the macro Activate, Reload, or Open Browser Tab:

  1. New Window If Not Found 0|1
  2. Reload Tab 0|1
  3. Browser Safari|Arc|Chrome|Brave|Edge|Vivaldi

EXAMPLES

For reference, here's the documentation for SearchLink, Gather, and Browser (Activate, Reload, or Open Browser Tab macro).


Example 1: SearchLink

If the following text is selected:

"WhichSpace" readme macOS desktop spaces

The macro replaces the selected text with:

[WhichSpace](https://github.com/gechr/WhichSpace/blob/master/README.md)


Example 2: Gather

If the following text is selected:

https://tpcc.org

The macro replaces the selected text with:

[Church in Indianapolis | Traders Point Christian Church](http://tpcc.org)

Current Series

We all have pieces of our lives before Christ that we try to hold onto, but God wants to transform the entire landscape of our hearts. He calls us to be His Church, where the rest of the world can see God's love in action and find refuge in this wild world. 

From now through October, we'll study 1 Corinthians to learn how to view every area of our lives and ministry through the gospel lens. 

[Watch Messages][1]


[1]: http://tpcc.org/messages

Example 3: Browser

If the following text is selected:

https://apple.com

the Apple homepage is opened.


Example 4: SearchLink followed by Gather

If the following text is selected:

"%TriggerBase%" Keyboard Maestro wiki

the macro replaces the selected text with:

[%TriggerBase%](https://wiki.keyboardmaestro.com/token/TriggerBase)

The _%TriggerBase%_ token returns the trigger type. 

The token will return one of these, which corresponds exactly to the name of each trigger as shown when clicking the New Trigger button: 
    
    
    Hot Key Trigger 
    Global Macro Palette Trigger
     Status Menu Trigger
     Typed String Trigger
    Application Trigger
    Audio Output Changed Trigger
    Clipboard Changed Trigger
    Clipboard Filter Trigger
    Cron Trigger
    Dragged File Trigger
    Engine Launch Trigger
    Focused Window Trigger
    Folder Trigger
    Gesture Trigger
    Idle Trigger
    Login Trigger
    MIDI Trigger
    Mounted Volume Trigger
    Periodic Trigger
    Public Web Trigger
    Remote Trigger
    Sleep Trigger
    Time of Day Trigger
    USB Device Key Trigger
    USB Device Trigger
    Wake Trigger
    Wireless Network Trigger

## See Also

#### Tokens

Example 5: SearchLink followed by Browser

If the following text is selected:

"Baseball Rules" mlb

the macro replaces the selected text with:

[Baseball Rules](https://www.mlb.com/glossary/rules)

And the URL is opened in the browser.


MACRO DIALOG

The macro dialog buttons can be selected using the keyboard:

Button Key Note
SL→ B return SearchLink followed by Browser
S𝗟→ G l SearchLink followed by Gather
đť—•rowser b Activate, Reload, or Open Browser Tab
đť—šather g Gather by Brett Terpstra
đť—¦earchLink s SearchLink by Brett Terpstra
đť—–ancel c dismiss the dialog

SANS DIALOG

If the macro is triggered using the secondary trigger, the one that includes the Shift key (⇧), or if the %TriggerValue%* is sans dialog, then the macro will not display the macro dialog and will execute using the previous run options. This mode is useful when one wants to repeatedly trigger the macro with the same options for several text strings.

*This can be set by running the macro using Execute a Macro action (or via AppleScript) and specifying sans dialog using the With Parameter.


SETTINGS

local_SearchLinkGemPath : See the SearchLink installation instructions.

The macro dialog includes four options. The following settings dictate the default value of these options*.

local_RichLinks_default : 1 If SearchLink is run and the selected text is within a rich text editor, e.g., TextEdit or Mail, the selected text will be replaced by a rich link (versus a markdown link [title](url)).

local_NewWindowIfNotFound_default** : 1

local_ReloadTab_default** : 0

local_Browser_default** : Safari

*Interactive changes of the dialog options are retained (for subsequent runs of the macro). However, the options can be easily reset to the default settings. For instructions, see the dialog.

**For the last three settings, see Activate, Reload, or Open Browser Tab.


INSTALLATION OF REQUIRED COMPONENTS

This macro requires three components:

  1. SearchLink, v2.3.71+

    • Download and install using the standard installation instructions.
    • Follow the instructions: Install as a Gem
    • Open the macro and confirm that the variable local_SearchLinkGemPath is properly set.
  2. Gather CLI, v2.1.6+

    • Download and double click to run the Gather CLI installer. Alternatively, the Homebrew instructions can be used.
  3. Activate, Reload, or Open Browser Tab, v4.0+

    • Download and install the macro.

ACKNOWLEDGEMENT

The RichLinks option is implemented using an adapted version of a JXA script that is within the macro Copy Markdown as Link, by @ComplexPoint.


TESTED WITH

• Keyboard Maestro 11.0.3
• Sequoia 15.1 (24B83)/MacBookPro18,2
• Mojave 10.14.16/Macmini6,2
• High Sierra 10.13.6/iMac11,1445


VERSION HISTORY

( expand / collapse )

1.0 - initial version

2.0
a) Added the Rich Links setting/option.

b) Interactive changes of the dialog options are retained (for subsequent runs of the macro). However, the options can be easily reset to the default settings.

c) Added the sans dialog mode.

3.0
a) Smart double quotes are converted to dumb double quotes before text is processed by SearchLink.

b) Bug fix: In the macro dialog, the Cancel button can now be properly selected using the c key.


Download: Run SearchLink- Gather- Browser.kmmacros (115 KB)

Macro-Image


Macro-Notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.

System Information
  • macOS 15.1 (24B83)
  • Keyboard Maestro v11.0.3

SearchLink (with RichLink)

Ex1


SearchLink (Amazon) followed by Browser

Ex2


SearchLink followed by Gather

Ex3


SearchLink Help

Ex4

3 Likes

I'm stoked to try this. It may prove quite convenient for posting fediverse comments. Thank you!

1 Like

I've updated the OP with Version 2.0 of Run SearchLink, Gather, Browser:

  • Added the Rich Links setting/option.

  • Interactive changes of the dialog options are retained (for subsequent runs of the macro). However, the options can be easily reset to the default settings.

  • Added the sans dialog mode.

I've updated the OP with Version 3.0 of Run SearchLink, Gather, Browser:

  • Smart double quotes are converted to dumb double quotes before text is processed by SearchLink.

  • Bug fix: In the macro dialog, the Cancel button can now be properly selected using the c key.