Skip to content

Instantly share code, notes, and snippets.

View carlsmith's full-sized avatar

Carl Smith carlsmith

  • Cambridgeshire, UK
View GitHub Profile
@carlsmith
carlsmith / maestro.py
Last active March 9, 2024 06:03
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)))