|July 10, 2018|
Execute Shell Script
One of the nice things about https://www.keyboardmaestro.com/main/ is the ability to run Shell Scripts as part of a Macro action. This is useful when you want to apply a clipboard text to a shell script or just to execute a shell command.
Recently I wanted to set up a Status Menu action to simply run a shell script. I am doing some automation work and frequently need to test code changes. it's just easier to have a status menu than to open up a terminal and execute the run command.
To execute commands, simply use the Bash Shell:.
Some Notes about Shell Execution
- You can ignore the output results. (nice feature if you don't need to see the debug information)
- I have an ampersand after the run_automation.sh so the command would run in the background. There is the ability to run the command asynchronously in Keyboard Maestro.
- In my execution script, the directory where it's being executed from makes a difference, so I needed to change directory before running the command. I didn't use the 'Script File' method.
- To run PHP commands you would type in: #!/usr/bin/php
Oh, more thing, if I want to run the command frequently, I can instantly change the macro to be included in the Global Macro Palette. It's a simple switch of the trigger type.
There's a lot of options available, including the ability to pass variables to the shell command. The Keyboard Maestro help section has a lot of detailed information on setting those up.
Add your Comments
Feel free to leave a comment about this post.