Skip to content

Instantly share code, notes, and snippets.

@valpackett
Created November 10, 2011 17:48
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save valpackett/1355558 to your computer and use it in GitHub Desktop.
Save valpackett/1355558 to your computer and use it in GitHub Desktop.
Evernote-Marked integration

Evernote's Mac client + Marked or similar: basically just setting ~/Documents/Evernote Selection.md to the content text of current note converted from HTML to Markdown.

First,

$ [sudo] pip install html2text MacFSEvents

Then launch it and enjoy.

P.S. guess what, ⌘S works in Evernote.

#!/usr/bin/env python
import os
import time
import codecs
from html2text import html2text
from fsevents import Observer, Stream
home = os.environ["HOME"]
now = lambda: time.mktime(time.localtime())
last = now()
def cb(*args):
global last
if now() - last > 1:
codecs.open(os.path.join(home, "Documents/Evernote Selection.md"), "w", "utf-8") \
.write(html2text(os.popen("""osascript -e \
'tell application \"Evernote\"
if selection is not {} then
set the_selection to selection
return HTML content of item 1 of the_selection
else
return \"\"
end if
end tell'""").read().decode("utf-8")))
last = now()
cb()
observer = Observer()
observer.schedule(Stream(cb, os.path.join(home, "Library/Application Support/Evernote/data")))
observer.start()
       DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
               Version 2, December 2004

Copyright (C) 2011 Grigory V. floatboth@me.com

Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed.

       DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE

TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

  1. You just DO WHAT THE FUCK YOU WANT TO.
@rezzz-dev
Copy link

One step closer -- I ran the script locally by just doing python evernote_selection.py and everything seemed to work as expected. But for whatever reason, the script won't work automatically unless I drop to terminal and run it manually.

I've put the script in /usr/local/bin which is in my $PATH, just not happening automatically for whatever reason. Any thoughts?

@rezzz-dev
Copy link

Nevermind -- I got it -- my plist had the wrong location of the script - 👊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment