Skip to content

Instantly share code, notes, and snippets.

@yy
Last active September 9, 2018 14:27
Show Gist options
  • Save yy/7d679e13d78df581d498ef9f3dbd8782 to your computer and use it in GitHub Desktop.
Save yy/7d679e13d78df581d498ef9f3dbd8782 to your computer and use it in GitHub Desktop.
Create an Omnifocus project from a template file (the first argument). The variables should be written as: `{variable}`
#!/usr/bin/env python3
import re
import sys
if __name__ == "__main__":
template_path = sys.argv[1]
content = open(template_path).read()
var_pattern = re.compile('{.+?}')
variables = set(re.findall(var_pattern, content))
for var in variables:
var_str = input(f'{var}? ')
content = re.sub(var, var_str, content)
print(content)
@yy
Copy link
Author

yy commented Sep 9, 2018

On a Mac, one can run

template2ofproj.py template_file.txt | pbcopy 

to copy the result to the clipboard, which can then be pasted to OmniFocus.

An example template file:

Trip to {destination}: @parallel(false) @autodone(false) @due({due})
- Check passport @tags(Home) @due({due} -5w)
- Buy a plane ticket @due({due} -30d) @tags(Online, Computer)
- Book a hotel room @due({due} -28d) @tags(Online)

TaskPaper format reference: https://support.omnigroup.com/omnifocus-taskpaper-reference/

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