This action is similar to the default “Execute a Shell Script” action. The main difference is that the script will be executed in the Terminal application.
Example:
When would you use this?
Whenever you need the visual output of the Terminal
For interactive scripts
When the script demands a password, which you don’t want to send through KM
Installation
Drop the zip archive on the Keyboard Maestro application dock icon. (Wiki: Plug-in Actions)
If the “New Terminal window” option is not selected:
The action now also checks for “[Process completed]” windows and will treat them as busy windows. (As before, if all open windows are busy the script will be executed in a new Terminal window, independently of if the option is selected.)
To install the new version delete the old plugin from ~/Library/Application Support/Keyboard Maestro/Keyboard Maestro Actions/, then drag the zip file to the KM Editor icon in the dock.
No, the script will presumably inherit the environment of the Terminal and the Terminal window, not the AppleScript, so it will not have the Keyboard Maestro variables.
If you wish to use the Keyboard Maestro variables, you will have to read them from the Keyboard Maestro Engine using an AppleScript (via osascript) within the script.
Or failing that, pass the variables by some other mechanism (eg, the clipboard or a file).
You can paste your KM variables to the second text field (“KM variables”). To use them in your script call them with $km1, $km2, etc. in the order they are listed in the Variables field.
Example:
…produces this output:
Treat this as a beta version! I haven’t done much testing.
Before using it with file-system-changing commands like rm or mv please test it with something harmless like echo or ls !
Notes:
If you are using the action without any variables you can leave the explanatory text in the field. It will be ignored.
Empty lines in the Variables field or trailing newlines will be ignored.
Empty or undefined variables will not be ignored, they will become empty strings in the shell script.
If you prefer to see an alert if a variable is empty/undefined, this can easily be implemented. But I think in general it is good to have the possibility to run the action also with intentionally empty variables.
I am having some issues drag-dropping the zip into my Keyboard Maestro dock icon. When I try that, nothing happens. I do not see this plugin anywhere. I tried restarting the Keyboard Maestro app as well, but no luck. Is there something that I must do before drag-dropping?
Check if it gets expanded into ~/Library/Application Support/Keyboard Maestro/Keyboard Maestro Actions. That’s where it should be, unless @peternlewis changed something recently.
Just to be sure, restart also KM Engine. You can do this from the File menu within the KM app. (Last entry, “Quit Engine” / “Launch Engine”).
Check if it gets expanded into ~/Library/Application Support/Keyboard Maestro/Keyboard Maestro Actions .
My bad that I hadn't noted this earlier. I had a look there before posting, no, it is not visible on that path.
restart also KM Engine
This is something I tried as well, but no luck. This is actually a new Mac with a new installation of KM, and the old device works fine. I have sync enabled between the two, via Syncthing. Not sure if that might affect it.
Not sure either. But, since everything works on your other computer, this might be something.
I’m using KM’s own sync (Prefs > General) via iCloud. With this enabled, KM syncs a special “Keyboard Maestro Macros.sync” file. But as the name suggests, plugins may not be included with that sync either. I’m not sure about that; currently the plugins on my two Macs are in sync, but this can well be because they might have been installed on both machines. (Rarely that I install new plugins; I have only 4 in total, where two are obsolete…)
But: Are we speaking of a syncing issue, or did you have tried to install (zip-drop) the plugin on the other machine directly, and it didn’t work either?
The sync issue could be unrelated, as my understanding is the same as you -- third-party plugins cannot be synced.
Drag-dropping not working is the core issue. I want to try removing this plugin from working computer, and try adding it again, but I am a bit worried that I might lose it on that computer as well. Will continue investigating, will followup if I know more.
Well, I think you can’t lose anything because instead of expanding the Zip by dropping it on the KM Dock icon, you can always expand it “manually” into the path. Or did you try that and the plugin was not recognized?
I guess, it was my bad too, since I should have checked the structure of my archive and tell you to drop the Zip from the Dmg and not the “outer” Zip. Sorry.
I think I enclosed the Dmg in a Zip because the forum doesn’t accept Dmg uploads (at least back then when I uploaded it).
PS:
I noticed that the only hint that you have to mount the Dmg first, is a tiny line in my 2.1-update post that can easily be missed.
So, for other users, here in bold:
Download version 2.1 of the plugin, unzip it, mount the Dmg and follow the instructions there.
Thank you for this! I have some yt-dlp issues that I wanted to be able to monitor over the course of a few days. This works great, and might be the way I leave it even after debugging. tyvm
Glad to see that my old action still has users . I’m using it also in some macros, since running scripts in the normal shell and then propagating to a KM output is simply not an option in some cases, or is inconvenient.
I still hope that this will become a native KM action some day, as already asked to @peternlewis 7 years ago.
I think the reason he has not implemented it yet is because it has some potential pitfalls regarding variable parsing. For a user action it is OK-ish to be not perfect or even insecure, but for a native action things are different. Or maybe he just forgot.