/rerun

A linux command line program for watching a directory and rerunning a command when it's contents change.

Primary LanguageC

rerun

A linux command line program for watching a directory and rerunning a command when it's contents change.

BUILD

Requires gcc

make

You can copy 'rerun' into a local ~/bin or some other location that is on your PATH.

USAGE

rerun DIRECTORY FILE_PATTERN COMMAND...

DESCRIPTION

Watches DIRECTORY for changes in any file that matches FILE_PATTERN and then runs COMMAND. FILE_PATTERN should be in the glob format.

You probably want to wrap both the FILE_PATTERN and COMMAND in quotes, so the shell doesn't pre-expand patterns and the command is seen as a single argument.

Depends on inotify which is a Linux Kernel 2.6.13 and later feature.

EXAMPLES

rerun web/js "*.js" "juicer merge -min '' web/js/behavior.js"
rerun web "*.css" bin/package_site.sh

BUGS

  • rerun doesn't watch directories recursively.
  • rerun doesn't handle lots of file modifications in a short amount of time well. It will call your command multiple times.
  • Usage isn't written in stone and can be improved

LICENSE

This code is licensed under the Mozilla Tri-License MPL 1.1/GPL 2.0/LGPL 2.1

================================77777$$$$$$Z$$$OZZZOOOOOOOOOOOOOOZZ7++++++++++++
=======================~===~~+I7777$$777$Z$$$$$$ZZ$OOOOOOOOOOOOOOOOZZ7===+++++++
=====================7$~==~=7777$7$77$$$$$ZZ$ZO$$$$ZOOOOOOOOOOOOOOOOOO$+=+====++
================~=~~=OZ~~=II7$$$$$$7ZZZZ$ZZOZOOZZ$$$$$$OOZOZOOOOOOOZZOOZ?+=+====
============~==~~~=~~ZZ++7777$$$$$ZZZZZZZZZZZZOZZZZ$Z$$Z$ZZZOOOOOOOOZOOOZ?======
==========~~~~~~~~~~~$$77777$$7$$$$7ZZZZZOOOOOOOOOZZOZZOZOZOZOOOOOOOZZOOOZ?=====
==~~~~~~~~~~~~~~~~~~~I7777$7$7$ZZZZZZZOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO$ZOOOO=====
~~=~~~~~~~~~~~~~~~~~?7I77Z$$$ZZZZZZOOOOOOOOOOOOOO88O8888888888888888OOZOOOO?====
~~~~~~~~~~~~~~~~~~~I777$$$$ZZZZZZZOOOOOOOOOOOO8888888888888888888888OOOOOOO$====
~~~~~~~~~~~~~~~~:~777$$Z$ZZZZZOOZOOOOOOOOOO888888DDDDDD888888888888888OOOOO$====
~~~~~~~~~~~~~~~~+77$7$$$$ZZOOOOOOOOOO8O888888DNMMMMMMMNM8DMIZNNN8OO88888OOO$~===
~~~~~~~~~~~~~~:+777$$$$ZZZOOOOOOOO88888888NMMMMMMMMMNDD8$77I??78MMND88O88OO+~===
~~~~~~~~~~~~~:+I77$$$$$ZOOOOOOOOO8O888DNMMMMMMMMMMMMMMMMNMNMMMMMMMMMMNN8O8O==~~~
~~~~~~~~~~~~:=777777ZOZOOOOOO888888DNMNNND88OOO888OOZ$7I?????I7ZZ8DNMMMMNOO~~~~~
~~~~~~~~~:::+77777$ZZOOOOOOO8888DNNNDOOOZ$$ZZZOOZZZ$$$$$II????I77ZZO8MMMMMD~~~~~
~~~~~::~~::II7I7$ZOOOOOO88888DNNOZ$$ZZZZ7$Z$7$$ZZ$$777I?????III7777$ZOMMMMMI~~~~
:~~~:::::~?II7$ZZOOOOOO888DDNDOI++++I7777777$$$$7777I77$ZZ$$$$$$77777$DMMMMN=~~~
::::~::::I777$ZOOOOOO8O88NNNO$II7$$Z7?++I7777777I777$$Z888DDD8DDD888OZZNMMMN7~~~
~~::::::?I7ZZOOOOOO888DNMNNDN8NNNNDNN$I?+I7II777I77$Z8DDNNMMMMMMMMMMMM8OMMMM7~~~
::::::~I7$ZZZOOOOO88DNMMMMMNND88O$I??I7I+=+I?I77I77ZZO8888DDNNMNMMMMMMN8NMMM$~~~
:~:::=7$ZZOOOOOO88DMMMMMMNDO$7?II+++==++===???I77$7$ZZZOOO88OZ$7$Z$ONMNDDMMNN~~~
::::=I7ZZZOOOO888NMMNNMND$Z$$$$77???++=====??I7777$ZZZOOOOZ$$77II77Z8NND8NMMN~~~
:::~7$ZZOOOOO88DMMMMN8ZZZ$7IIII?II77?+?+=~++?I777$7$Z8OZ$$ZO888OOOOZODDDODNM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