python-shortcutsis a library to create Siri Shortcutson your laptop with your favourite text editor.It uses tomlto represent shortcuts.
The library is in a very early development state (PR welcome!), so it does not support all actions from Shortcuts app.
I wanted to convert my shortcut to a file in human-readable format. :)
From the code below this library can create a working shortcut:
[[action]]type = "ask"question = "What is your name?"[[action]]type = "set_variable"name = "name"[[action]]type = "show_result"text = "Hello, {{name}}!"
This library requires plutil
tool, which should be installed on MacOS by default.On Linux, you should be able to use plistutil
instead.
pip install python-shortcuts
If you need to convert existing shortcut to a toml file, at first you need to export it.Go into Shortcuts app, open the shortcut and share it. Choose "Share as file" and use this file with this library.
Convert toml
file with shortcut description to a real shortcut file.After you need to open the file with iOS Shortcuts app.
shortcuts what_is_your_name.shortcut what_is_your_name.toml
Also, you can convert shortcut file to a toml
:
shortcuts examples/what_is_your_name.toml what_is_your_name.shortcut
More examples of toml
files you can find here.And read the tutorial! :)
Run tests:
tox