Skip to content

Instantly share code, notes, and snippets.

@shenyubao
Created October 22, 2013 01:45
Show Gist options
  • Save shenyubao/7093961 to your computer and use it in GitHub Desktop.
Save shenyubao/7093961 to your computer and use it in GitHub Desktop.
Get Text From Omnifocus. (used in Geektools)
#!/bin/sh
# Ver 0.02
# Changes the handling of time zones
OFOC="com.omnigroup.OmniFocus"
if [ ! -d "$HOME/Library/Caches/$OFOC" ]; then OFOC=$OFOC.MacAppStore; fi
OFQUERY="sqlite3 $HOME/Library/Caches/$OFOC/OmniFocusDatabase2"
TODAY=$(date -v0H -v0M -v0S +%s) #Midnight at the start of today: set the time component to 00:00
NOW=$(date +%s) # the date command automatically allows for daylight savings like BST in the UK
DAY=86400;
ZONERESET=$(date +%z | awk '
{if (substr($1,1,1)!="+") {printf "+"} else {printf "-"} print substr($1,2,4)}')
YEARZERO=$(date -j -f "%Y-%m-%d %H:%M:%S %z" "2001-01-01 0:0:0 $ZONERESET" "+%s")
DUE="($YEARZERO + t.effectiveDateDue)";
DAY=86400
MATCHES="(t.dateCompleted is null and t.blocked=0)"
echo "Doing List:
"
$OFQUERY "
SELECT strftime('%w|%m|%d|%H:%M',$DUE, 'unixepoch'), p.name, t.name, t.estimatedMinutes
FROM (((task tt left join projectinfo pi on tt.containingprojectinfo=pi.pk) t
left join task p on t.task=p.persistentIdentifier)
left join context c on t.context = c.persistentIdentifier)
left join folder f on t.folder=f.persistentIdentifier
WHERE $MATCHES
AND t.flagged = 1
ORDER BY t.effectiveDateDue, f.name, p.name, c.name
" | awk '
function getmin(min){
if(min >= 60){
return "(" min/60 " hour)";
}
if(min){
return "(" min " min)";
}
}
BEGIN {FS="\|"; wkday=0; prj=0}
{
if (wkday!=$1) {wkday=$1;
}
print " • " $3 " "getmin($4)
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment