Keyboard Maestro includes a command line tool to let you execute macros from the shell command line. The tool is named keyboardmaestro
and is located within the Keyboard Maestro.app
application. Assuming the application is installed in the Applications folder, the command line tool will reside at:
/Applications/Keyboard Maestro.app/Contents/MacOS/keyboardmaestro
You may want to create a shell alias for it, or add /Applications/Keyboard Maestro.app/Contents/MacOS
to your PATH, or you can link to it from /usr/local/bin
with the command:
sudo ln -s '/Applications/Keyboard Maestro.app/Contents/MacOS/keyboardmaestro' /usr/local/bin/keyboardmaestro
Use --help
to list the argument options.
The command can pass a value to the macro (available via the %TriggerValue% token), and execute the macro asynchronously, or wait for the macro to finish, receiving a result (returned via the Return Result action) which is output to stdout.
Alternatively, the command can ask to edit the specified macro in the Keyboard Maestro editor.