Copy markdown to external app
I have a script that scrapes info from data sites and then formats it into a markdown file that makes it easy for me to read. I like to read my markdown files using the Bear app, and to do this i have to export my markdown file from pythonista by clicking share and then selecting the "copy to Bear" option. Is there any way to do this using code? thanks for any help...
@aidensala You can use console.open_in(file) to present the standard open_in window BUT you can't preselect the app you want, you will have to do it manually.
There exists a solution by a Pythonista script that
- copies your text file to the clipboard
- starts the Apple Shortcuts app with a shortcut that will:
- get the file from the clipboard
- give it a name (optional)
- open_in the file and setting "does not display the menu", thus you can there preselect the app you want
import clipboard import webbrowser url = 'shortcuts://x-callback-url/run-shortcut?name=OpenFileFromPythonistaInOneApp' with open('myfile.md') as fil: c = fil.read() clipboard.set(c) webbrowser.open(url)
@aidensala, there is also an extensive URL scheme for bear (google it, they have nice docs). With it, you can pass a file to be created in bear as a Base64-encoded URL parameter:
@mikael very good idea, I never thought about the url scheme to the wanted app 😢