Skip to content

Instantly share code, notes, and snippets.

@brandonpittman
Last active August 29, 2015 14:23
Show Gist options
  • Save brandonpittman/adf8e572a3c5bc75649a to your computer and use it in GitHub Desktop.
Save brandonpittman/adf8e572a3c5bc75649a to your computer and use it in GitHub Desktop.
JXA script for toggling "Considered" tasks in OmniFocus
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