View Single Post
Or simple text formatting from a pure shell script, for NerdTool, GeekTool, Terminal.app etc, without needing OmniFocus to be running.

Code:
#!/bin/sh
#OFOC=$(osascript -e 'tell application "Finder" to get id of application file id "OFOC"')
OFOC="com.omnigroup.OmniFocus" # For Appstore-purchased variant use (slower) line above instead
echo -e "FLAGGED AND NOT COMPLETED:\n"
sqlite3 $HOME/Library/Caches/$OFOC/OmniFocusDatabase2 '
SELECT c.name, p.name, tt.name 
FROM ((task t left join projectinfo pi on t.containingprojectinfo=pi.pk) tt 
left join task p on tt.task=p.persistentIdentifier) 
left join context c on tt.context = c.persistentIdentifier
WHERE tt.flagged=1 and tt.dateCompleted is null 
ORDER BY c.name, p.name' | awk '
BEGIN {FS="\|"; prj=0; ctx=0;}
{
	# Output a [CONTEXT] header whenever 1st col value changes,
		if (ctx!=$1)  {ctx=$1; if (length(ctx) < 1) {print "(no context)"} 
		else {print "[" ctx "]"}}; 
	# and output a project name whenever 2nd  col value [PROJECT] changes,	 
		if (prj!=$2)  {prj=$2; if (length(prj) < 1) {print "\t(Inbox)"} 
		else {print "\t" prj}};  
	# and output column 3 [TASK] if it differs from col 2
		if ($3!=$2) {print "\t " $3}
}'

Last edited by RobTrew; 2012-08-02 at 08:26 PM..