Last active
August 29, 2015 14:23
-
-
Save brandonpittman/adf8e572a3c5bc75649a to your computer and use it in GitHub Desktop.
JXA script for toggling "Considered" tasks in OmniFocus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
of = Library('OmniFocus') | |
sel = of.selected() | |
app = Application('OmniFocus') | |
app.includeStandardAdditions = true | |
sel.forEach(function(task) { | |
pattern = /^(Consider) (.+ing) (.+)$/ | |
name = task.name() | |
if (pattern.test(name)) { | |
words = name.split(' ').slice(1) | |
verb = words[0] | |
verb = verb.split('') | |
verb[0] = verb[0].toUpperCase() | |
verb = verb.slice(0,-3).join('') | |
words[0] = verb | |
task.name = words.join(' ') | |
try { | |
task.context = task.containingProject().context(); | |
} catch (e) { | |
console.log(e); | |
task.context = null; | |
} | |
} else { | |
words = name.split(' ') | |
head = words[0].toLowerCase() | |
rest = words.slice(1).join(' ') | |
task.name = 'Consider ' + head + 'ing ' + rest | |
task.context = of.getContext('Considered') | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment