Quote:
Originally Posted by kingsinger
... how would I make a shell script out of one of my queries that I could use to update a geek tool text file via Hazel whenever the OF cache is updated?
|
For Hazel, your OF database will likely be in one of these two locations (depending on how you purchased it):
- Library/Caches/com.omnigroup.OmniFocus/OmniFocusDatabase2
- Library/Caches/com.omnigroup.OmniFocus.MacAppStore/OmniFocusDatabase2
For the script side of things here's an example of one of mine:
Code:
#!/bin/bash
FILE=~/Desktop/"REPORT-WORK-`date +"%Y-W%V-%h-%d"`.taskpaper"
ofexport \
-T taskpaper-lite \
-o "$FILE" \
-f 'text=^Work$|^Miscellaneous$' \
-E \
-p text=Routine \
-p text=Repeat \
-I \
"$@" \
-a flatten \
-a prune \
-E \
-t text='SEQ|PAR' \
-f sort
I like breaking the command over multiple lines like this so I can see what's going on. Note that the "$@" is shell variable that inserts any additional command line arguments at that point - allowing you write scripts that use other scripts etc. This is my base "work" script, I have other scripts that use this and add filters for showing and sorting by just due or just done etc. I often run "work --open" to create and open the file, for example.
You'll need to run "chmod +x myscript" on your script ro make it executable (and then make sure it works!) because diagnosing problems when the happen in Hazel is a pain. You may need to refer to your script via it's full path - rather than just by name, I'm not sure where Hazel gets it's environment from.
Finally, the Hazel recipe for generation is something I'm still playing with. I don't want it to run too often (I have about 5 uses of ofexport triggered and it uses a lot of CPU). Also if ofexport is reading continuously, it can block OF from writing so to trigger and throttle I have:
- Full Name is <database>
- Date Last Modified in in the last 5 mins
- Date Last Modified is NOT in the last 4 mins
- Date Last Matched in NOT in the last 4 mins
I don't fully understand exactly how Hazel rules are interpreted but the abve seems to do what I want.
Embedded Script:
Code:
. /Users/psidnell/.bashrc
/Users/psidnell/Workspace/Bin/hazel/of_modified