Keyboard Maestro has an action to run a Shell Script. This action lets you run a script file or a text script entered into the action’s text field in the edit mode of the macro. The output of the shell script can be shown in a window, in a notification, typed or pasted into the current text field, or saved to a clipboard or variable. This is useful for multiple-step macros where the output of one action is the input of another.
However, Shell Scripts can also take input by the means of variables set in Keyboard Maestro’s preferences, or set by other actions, even in other macros. This is the cause of the shell script action not working, as the variables in Keyboard Maestro are set in environment variables so that the shell script can access them. Environment variables have a maximum size, so if your variables are too large, then the shell script action will stop working, without showing any error. This can be quite confusing as no error is presented to the user. Even the shell script results box doesn’t open and display any output.
Here’s how you can fix it so that the Keyboard Maestro Execute Shell Script actions function again:
- Open Keyboard Maestro Editor (click the Keyboard Maestro icon in the menu bar and choose Launch Keyboard Maestro Editor).
- Go to Keyboard Maestro → Preferences (⌘,) → Variables.
- Select all the variables in the list and delete them with ⌫ or the delete button at the bottom of the window.
That’s it—run your macro again and the action should work! If it breaks again in the future, you can simply repeat this procedure to clear the variable causing the scripts to not run and try again. This also applies to the Execute AppleScript action as the environment variables are set there too so that they can be accessed through “run shell script”.