Share file or script to GitHub Gists


I’ve been working on a script that makes it easy to share files and scripts to GitHub Gists. I thought I wanted to share it, partly because I hope others can use it and partly because I think it’s a good example of performing a few actions with Scriptable including:

:bust_in_silhouette: Performing an OAuth flow.
:repeat: Using Scriptables URL scheme to implement x-callback-url in your scripts.
:closed_lock_with_key: Storing and accessing sensitive data using the Keychain API.

To use the script you must register an app on GitHub. It only takes two minutes and GitHub has a guide explaining how to do it:

After creating an app on GitHub, run the script and it will prompt you to enter the client ID and secret obtained after creating the app.

You can get the script from GitHub Gists:

Here’s a video that shows the script running:

I also made two shortcuts to go with the script. The first shortcut uses Scriptables URL scheme to create a gist from text or a file:

The second shortcut takes the URL to a gist as input and downloads the files in the gist.

Let me know if you experience any issues with the script or the shortcuts or if it’s useful to you :blush:


I’ve made a script to import scripts from Github Gists. You can find it here:

1 Like

I’ve added this piece of code

let fileURLs = args.fileURLs
if (fileURLs && fileURLs.length) {
	for (let f of fileURLs) {
		await updateOrCreateGistWithFile(f)

just below the definition of ACCESS_TOKEN_KEY to enable creating Gists from the share sheet! (you have to enable File URLs to be accepted from the share sheet in the scripts settings menu)