Permalink
Browse files

Add inotifyrun.

  • Loading branch information...
1 parent 0e2bfc1 commit fe905170bcf3dcf8d6518b945367ffa325cf4176 @SimonSapin committed Oct 13, 2011
Showing with 21 additions and 0 deletions.
  1. +2 −0 README.md
  2. +19 −0 inotifyrun
View
@@ -10,3 +10,5 @@ See the associated [blog posts](http://exyr.org/tags/snippets/):
](http://exyr.org/2011/gnome-terminal-tabs/)
* [Single-threaded event loop for file input and timers
](http://exyr.org/2011/event-loop/)
+ * [Run a script on file changes with inotify
+ ](http://exyr.org/2011/inotify-run/)
View
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+# Run the script given as arguments once and then every time a file changes
+# in the current directory.
+#
+# You may need to install the `inotify-tools` package.
+#
+# See more details at http://exyr.org/2011/inotify-run/
+#
+# Author: Simon Sapin
+# License: BSD
+
+
+FORMAT=$(echo -e "\033[1;33m%w%f\033[0m written")
+"$@"
+while inotifywait -qre close_write --format "$FORMAT" .
+do
+ "$@"
+done

0 comments on commit fe90517

Please sign in to comment.