Skip to content

Instantly share code, notes, and snippets.

@joelcarranza
Last active August 29, 2015 14:23
Show Gist options
  • Save joelcarranza/cc5d88553ed9cdcafa26 to your computer and use it in GitHub Desktop.
Save joelcarranza/cc5d88553ed9cdcafa26 to your computer and use it in GitHub Desktop.
/*-------------------------------------------------------------------
Create Omnifocus Task For Active Tab
Quickly create a task for a given tab. The task title is the name of
the tab and the note contains a URL to that tab
Source:
https://gist.github.com/joelcarranza/cc5d88553ed9cdcafa26
-------------------------------------------------------------------*/
app = Application('Chrome');
app.includeStandardAdditions = true;
tab = app.windows[0].activeTab();
tabTitle = tab.name();
tabURL = tab.url();
// TODO: verify OmniFocus is running and otherwise launch
var OF = Application('com.omnigroup.OmniFocus2');
OF.includeStandardAdditions = true;
// TODO: select context based on general context ?
var gksContext = OF.defaultDocument.flattenedContexts.whose({name:'GKS'})[0]
var taskName = tabTitle;
taskName = taskName.replace(/\s*- JIRA$/,'');
// scan for appropriate projects to place task
task = OF.Task({name:taskName,note:tabURL,context:gksContext});
OF.defaultDocument.inboxTasks.push(task);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment