Versioning shortcuts

Cross posting warning - I also asked on the MPU forum. I’m a recovering programmer. If I write code I want it versioned.

Now Shortcuts exist on MacOS has any found an elegant way to export them from the SQLlite database they live in and turn them into a text file (JSON, XML, ???) for versioning? Bonus points if we could use the text file for recovery in the event of a problem.

This doesn’t save the Shortcut as a text file, but saves it as a .shortcut file. This file is named the same as the Shortcut but with a date-time stamp suffixed to act as version control. Tapping on the saved file will reimport it as a new Shortcut — including the suffix in the new Shortcut name so it won’t overwrite any other versions. The name can then be changed if required.

Save Shortcut

Hope this helps.

That’s a start. Ideally we would export to text so you can see if a shortcut has changed or not.

I already do this with KM Macros - once a week they’re all exported to text files. Next time I do a git commit/push if there are any changes they get saved to version control. By saving the files this way I need to know if there is a change or not.

From the way the question was posted, my understanding was that you wanted something to run when you had changed the Shortcut and wanted to create a new locked in time version for version control.

I don’t wait for a once a week automated task to perform versioning exports – I trigger taking a versioned copy when I am at a point that I want to be fixed in time. I log the changes to the Shortcut in a change log file for that Shortcut maintained in Obsidian.

I do automatic daily backups of my Shortcuts independently of versioning.

There are ways to extract the Shortcuts to XML and JSON, but it is not something that I have played with so far. If you are a member of Club MacStories, there are articles on there where Federico Viticci and John Voorrhees show this in use (most recently in Issue 307, 11 February 2022 which covers both XML and JSON exports).

Thanks I just joined MacStories and will see how that plays out.