‘Tis the season… for iOS automation, I guess.

Almost exactly one year ago I blogged about my workflow for publishing new posts from my iOS devices with the help of Ole Zorn’s iOS app Pythonista. For someone like me, who does not use Python on a regular base, it was a pretty ambitious attempt, because it used the pygithub3 module for pushing new content and some custom UI for user interactions from the iOS share sheet.

Pythonista and Working Copy running in Split View Mode on iPad

Back then, I neglected all existing Git clients for iOS, because I couldn’t think of them being anywhere near as useful as the one running on my Mac. But there’s one particular called Working Copy by Anders Borum that’s really close. Due to its closed nature, iOS data exchange between apps is still somewhat cumbersome, but gladly, Anders knows all the tricks of the trade: Working Copy registers itself as iOS Document Provider, has a built-in WebDAV server, and offers a pretty extensive URL schema. Yes, you can really integrate your Git work flow with iOS editors like Coda or Textastic.

Sadly, there’s no such integration yet with Pythonista, but you can get really far with just using Working Copy’s URL scheme.

Here’s the idea: I really wanted to keep all my Pythonista scripts at Github, because… well, that’s where code belongs, I guess. Plus, being able to easily clone them on my Macs for further development, is a huge win for me.

So, I came up with two small Python scripts which do exactly that: Pushing new code to, and replacing old code by pulling changes from a Github repository:

[^gist]

They’re really simple, as you can see. Depending on an argv parameter, the update_repo script builds URLs for either writing or reading file changes, and launches the Working Copy app. For writing, Working Copy will present a view where you can enter your commit message and choose to either save (git add), commit, or commit and push. For reading, it will pull changes from the remote repository, applies them locally and returns file’s new contents via x-success parameter back to Pythonista, where update_script is called to update the script file.

Working Copy and Pythonista on iPad

Working Copy and Pythonista on iPhone

There are obvious limitations like the fact that you cannot easily update all your scripts at once, and that “local” changes are vicouisly overwritten, but at least it’s something ;)

If you believe Apple CEO Tim Cook, the iPad is the future of computing. It might be for him, but for someone like me it still seems quite far away, though I’d love giving up my MacBook Pro for an iPad Pro, if I only was able to get my work done on it. 2016 wasn’t the year for that, but small improvements like these make me a little more confident that we’ll get there some day.