Skip to content

Instantly share code, notes, and snippets.

@timothyekl
Created July 26, 2011 20:33
Show Gist options
  • Save timothyekl/1107942 to your computer and use it in GitHub Desktop.
Save timothyekl/1107942 to your computer and use it in GitHub Desktop.
Watch a directory recursively, recompiling .tex files on changes
require 'rb-inotify'
notifier = INotify::Notifier.new
notifier.watch('.', :modify, :recursive) do |event|
if event.name.end_with? ".tex"
puts "#{`date`.chomp}: Modified #{event.name}; recompiling..."
`pdflatex -interaction batchmode -output-directory #{File.dirname(event.absolute_name)} #{event.absolute_name} > /dev/null 2>&1`
end
end
notifier.run
@timothyekl
Copy link
Author

Turns out that rb-inotify has a :recursive option.

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