Reaching out to a comamnd line script?

Hey Popclippers! :wink:

I like this installing of extensions via a text with # popclip as the first line. It is a great and quick way to add some new functionality!

Instead of calling JavaScript, can I reach out to a command line script here? (Which, for example, takes the selection as stdin or as parameters and produces the new text for the selection as stdout, or something similar in this vein.)

1 Like

You can indeed. Here’s an helloworld example:

# #popclip
# name: Hello Shell
# icon: hi
# after: show-result
# interpreter: zsh
echo -n "Hello, ${POPCLIP_TEXT}"

or with input via stdin:

# #popclip
# name: Hello Shell
# icon: hi
# after: show-result
# interpreter: zsh
# stdin: text
input=$(cat)
echo -n "Hello, ${input}"

Docs: https://github.com/pilotmoon/popClip-Extensions/#shell-script-actions

1 Like