Sunday, February 27, 2011

react, a command line tool for inotify

Yes, it's 2011 and I am still using vim for software development. Damn, this
editor is so good ;-). But it is not an IDE. Thus, one thing I was missing is
automatically executing the compiler or the test suite.
Fortunatelly, there is the inotify API on Linux and associated inotify tools. They let you register callbacks in the user land when something happens on the file system. And even better, there is the PyInotify project, which provides Python bindings for inotify.
So, I went on and wrote react,
which is a command line tool for inotify that is based on PyInotify.
This tool monitors a directory recursively and triggers an external
script every time a file that matches a user provided regular expression
or shell file pattern is created or modified.
This tool really speeds up my vim-based software development. And it
shows the value of bindings to a scripting language as I managed to
finish the tool in under two hours. And as a side note: Python's argsparse is awesome! It is so good that I accepted to depend on Python 3.2. Hopefully this does not exclude too many users for now.