Alfred Evernote Snippets

This is sort of a plugin to a great OSX app, Alfred. It adds all notes in Evernote “Snippets” Notebook as a quick-paste snippet in Alfred.

I use both alfred and evernote extensively, so Im quite happy about this one!

Usage

  1. Provided you have Evernote, Alfred and powerpack and this workflow installed
  2. Put some snippets in “Snippets” notebook in evernote
  3. Hit afred `s your_note_title`
  4. enter
  5. note content is now pasted to your focused window

Download

Workflow on Packal

Alternative download here

Making of:

============================
Script filter:
var q = "{query}";
var values = Application('Evernote').findNotes("notebook:Snippets " + q);
var ret = '<?xml version="1.0"?><items>';
for (var i=0; i<values.length; i++ ) {
var title = values[i].title();
var val = values[i].htmlContent().replace(/<br\/>/g,'{enter}').replace(/<[^>]*?>/g,"");
var sub = values[i].htmlContent().replace(/\n/g,'').replace(/<[^>]*?>/g,"");
ret += '<item arg="'+val+'"><title>' + title + '</title><subtitle>' + sub + '</subtitle></item>';
}
ret += "</items>";
============================
You will need this to properly handle spaces (script filter has trouble with that)
NSAScript (synchronous)
on replace_chars(this_text, search_string, replacement_string)
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end replace_chars
on alfred_script(q)
return replace_chars(q, "{enter} ", "\n")
end alfred_script

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s