QA Graphic

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.

Simple Setup

To execute commands, simply use the Bash Shell:

.

Keyboard Maestro Shell Script

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.

 

About

These posts showcase some excellent examples of why Keyboard Maestro is a must-have for every Mac OS user. As a powerful automation tool, Keyboard Maestro helps boost productivity, save time, and streamline repetitive tasks. With its vast array of customizable features and functions, it's the perfect choice for Mac OS users seeking to optimize their workflow.

Schedule

WednesdayKeyboard Maestro
ThursdayGluten Free
FridayMacintosh
SaturdayInternet Tools
SundayOpen Topic
Monday Media Monday
TuesdayQA