rerun /

Filename Size Date modified Message
10 B
101 B
1.6 KB
17 B
1.7 KB
3.1 KB
255 B
12 B
4.3 KB


Command-line executable Python script to re-run the given command every time files are modified in the current directory or its subdirectories.


rerun [--help|-h] [--verbose|-v] [--ignore|-i=<file>] [--version] <command>


<command>           Command to execute
--help|-h           Show this help message and exit.
--ignore|-i=<file>  File or directory to ignore. Any directories of the
                    given name (and their subdirs) are excluded from the
                    search for changed files. Any modification to files of
                    the given name are ignored. The given value is
                    compared to basenames, so for example, "--ignore=def"
                    will skip the contents of directory "./abc/def/" and
                    will ignore file "./ghi/def". Can be specified multiple
--verbose|-v        Display the names of changed files before the command
--version           Show version number and exit.


Rerun detects changes to files by polling file modification times once per second. It looks in the current directory and all its subdirectories. On detecting any changes, it clears the terminal and reruns the given command.

It always ignores directories called .svn, .git, .hg, .bzr, build and dist.

It always ignores files ending with .pyc or .pyo.


rerun python -m unittest mypackage.mymodule

will rerun your tests every time you save your source code, but it won't rerun the tests a second time when .pyo files get updated as a result of executing the tests. Handy for seeing the new test results in another console window after you hit 'save' in your editor, without having to change window focus.


Tested on MacOSX, Ubuntu, WindowsXP, Windows 7.

Tested under Python2.7 or 3.2. May run under Python 2.6 or older with PyPI package 'argparse' installed.

No other dependencies.


pip install rerun

Known Problems

Polling for modification times perhaps isn't ideal. Registering of OS-specific notifications of file system events might be better. In practice though, I haven't noticed it burden my machine in directories containing hundreds of files.

It might be handy if '--ignore' accepted globs, e.g. "*.tmp"

See issues at


PyPI package 'watchdog' is a cross-platform library for handling file-system events, which includes script 'watchmedo', which looks like a more serious and heavy-duty version of 'Rerun'.


The idea came from the Bash command 'watch', and inspiration for this implementation came from an old blog post by Jeff Winkler, whos website seems to have now died.


Documentation & download:
Souce code and issues:
Contact the author:
 Jonathan Hartley, email: tartley at domain, Twitter: Jonathan Hartley.