The other day I tried to export my Siri Shortcuts / Workflows to Working Copy to have them properly versioned in git.

Iterate over the workflows and pass them on encoded as base64

By default the exported Workflows as seen above will be written in the binary variant of the PList format. Git is only optimized for text content, which is why there will be no diffs and so it will always store the entire file.

Pythonista to the rescue. With the following few lines of Python the file can be converted into the XML PList format:

import clipboard
import binascii
import plistlib
import webbrowser

def main():
	input = clipboard.get().encode("utf-8")
	binplist = binascii.a2b_base64(input)
	plistdata = plistlib.loads(binplist)
	xmlplist = plistlib.dumps(plistdata).decode("utf-8")
	clipboard.set(xmlplist)
	webbrowser.open("workflow://")

if __name__ == '__main__':
	main()

You can use this by putting the binary file content into the clipboard (encoded in base64) and invoke this script from Workflow. Once the execution flow returns back to Workflow you’ll find the XML encoded plist in the clipboard.

Receiving back the element after Pythonista

I haven’t played much with the Plist classes in Python but this might come in handy if you want to read or modify plist files.