Saturday, March 15, 2014 ∞
This site is so fast and smooth because it is statically built with Jekyll and a few days ago I released TakeIt, another kind of static site generator. Running a build script after you make a change to a site is slightly inefficient for most of my needs, so I decided to see if I could get a decent watch script built with Hazel. With some help from my resident Hazel expert, C. Nordengren, I came up with a decent solution.
For Jekyll I set the folder to watch to
_posts/ and for TakeIt I set it to watch the
images/ folder. It keeps track of changes in modification, if the filename has changed, and if the file is new.
The downside is that when you first set this up for an existing project, I recommend letting the rule run once without setting the Run shell script portion. It will rebuild once for every item it matches, which can be processor intensive. I do not add a lot of changes at once for my stuff, so this works for me. This also assumes you are not using the file’s Spotlight comments for anything, which is a pretty safe assumption.
The Hazel Rule
If any of the following conditions are met:
- Date Last Matched: is before Date Last Modified
- Date Last Matched: is blank
- Comment: is blank
- Passes AppleScript: embedded script:
Do the following to the matched file or folder:
- Add comment: with pattern filename
- Run shell script: embedded script: