Requirements or regex against current clipboard

Hi
I have been building workflows in PopClip lately to help with making life easier. I often have to ssh to remote servers, specifying a specific jump host depending on the region to which I am connecting. I issue a command similar to:
ssh -J jump-host ip-address
I have created a snippet to do this in a way…

First I copy the jump-host to the clipboard, then I select the ip-address. My snippet has a regex requirement to be visible in the menu if the selected text matches an ip-address, so I click it. This then adds the existing clipboard and the selected text together, opens a new iTerm tab and sends ssh along with the concatenated string. This all works, and I am very happy!

What I would like to do is add another filter/requirements/regex to this so that if the existing clipboard text does not match the format of a jump-host name, then the snippet will not get activated. This would just keep the pop-up menu cleaner should I select an ip-address without first copying the jump-host into the clipboard. It would also prevent me making errors (as I occasionally do) by selecting the ip-address and hitting my extension icon without remembering to get the correct jump host first.

I am not sure if anyone else would find this useful, but I have several snippets I use daily that would benefit from this.

1 Like

See the regex property: Actions — PopClip Developer

A Regular Expression to be applied to the selected text. The action will appear only if the text matches the regex, and the matching part of the text is passed to the action.

The regex property is described as: “A Regular Expression to be applied to the selected text.” This is what I already use in my snippet to match an ip address. What I would really like is “A Regular Expression to be applied to the existing contents of the clipboard”. I know I can do that in the code of the snippet, but I can’t use that to enable or disable the snippet’s icon in the pop-up menu in order to reduce clutter.

There is a way to do this but only for JavaScript actions. Using a custom population function to determine the extension’s actions. This could check the pasteboard.text global and act accordingl. However it sounds like you acrtion may be a AppleScript action, in which case this is not available unfortunately.

There is a way to do this but only for JavaScript actions. Using the “dynamic” entitlement you can a custom population function to determine the extension’s actions. This could check the pasteboard.text global and act accordingly. However it sounds like you action is probably a AppleScript action, in which case this is not available.

Thanks! Yes, the current action I am working on is AppleScript. Thanks for your input.