I am trying to use shell script in order to encrypt/decrypt the selected text with GPG. This command works fine in Terminal:
echo "Test text" | gpg -c --no-symkey-cache | openssl enc -base64 -A | pbcopy
GPG prompts for password and sends encrypted text to clipboard.
In Keyboard Maestro I don't see GPG prompt for password and nothing is returned to clipboard. I used the copy action and then the command
gpg -c --no-symkey-cache | openssl enc -base64 -A | pbcopy
How could you? Keyboard Maestro is not a terminal and isn't interactive.
GPG is not installed by default on macOS as far as I know.
How did you install it? Where is it? E.g. where in the $PATH?
Keyboard Maestro doesn't use your bash (or other) profile in its execute-shell action, so GPG is probably not in the default $PATH KM uses.
Take a peek at this thread:
Create a PATH Environment Variable for Keyboard Maestro and Add /usr/local/bin to the Default Path
There're more discussions about this on the forum, and a fair bit of info on the Wiki:
Execute a Shell Script action
Other encryption tools I've used allow you to pass the password as a parameter, so you can use a Prompt for User Input action to enter your password and pass it to the Execute a Shell Script action.
If you can't get it figured out holler.
Thank you! It was just a PATH environment that was causing the problem and your advice fixed everything.
As regards GPG it is a Mac app that installs Command Line Utility by default. When you run the script GPG's dialog box pops up asking for password. This was a deliberate choice as I don't want to keep the password in plain string within KM script.
encrypt:decrypt text.kmmacros (7.2 KB)
Hi @andrej, the macro does not work for me. Do you have to activate something else or unlock?
When I run this in the terminal, it works.
No, there is nothing special to be installed apart from GPG. But if it works in command line I would guess you need to set the ENV_PATH variable as Chris explained above.
Thanks for the tip @andrej. It works very well now. Thanks for sharing your macro. It saves me a lot of work