Skip to content

Instantly share code, notes, and snippets.

@jbwhaley
Last active April 17, 2020 08:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jbwhaley/5898291 to your computer and use it in GitHub Desktop.
Save jbwhaley/5898291 to your computer and use it in GitHub Desktop.
A tweaked version of Federico Viticci's [workflow for sending clipped text and a URL to Drafts.app](http://www.macstories.net/stories/automating-ios-how-pythonista-changed-my-workflow/).
import sys
import webbrowser
import console
import urllib
numArgs = len(sys.argv)
base = 'drafts://x-callback-url/create?text='
if numArgs == 3:
clip = sys.argv[2]
link = sys.argv[1]
if clip =="":
text = "[from](" + link + "):" + "\n" + "\n"
text = urllib.quote(text, safe='')
else:
text = "[from](" + link + "):" + "\n" + "\n" + "> " + clip
text = urllib.quote(text, safe='')
else:
text = console.input_alert('Drafts', 'Enter your draft below')
text = urllib.quote(text, safe='')
webbrowser.open(base + text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment