Skip to content

Instantly share code, notes, and snippets.

@carlsmith
Last active March 9, 2024 06:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlsmith/bc699f02e1b25513fc8dde5bb74106ca to your computer and use it in GitHub Desktop.
Save carlsmith/bc699f02e1b25513fc8dde5bb74106ca to your computer and use it in GitHub Desktop.
IPython line magic for running a Keyboard Maestro macro by name.
import os
from IPython.core.magic import register_line_magic as line_magic
@line_magic
def maestro(name):
quote = lambda text: '"{}"'.format(text)
command = " osascript -e 'tell application {0} to do script {1}' "
os.system(command.format(quote("Keyboard Maestro Engine"), quote(name)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment