watchexec 1.0.1

monitor a filesystem for changes to execute a command

To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:


watchexec is a simple, standalone program that watches a path for changes and runs a command when it detects any modifications.


  • simple invocation and use
  • monitors one or more root directories recursively for changes
  • support watching only files with specific file extensions
  • automatically uses ignores from .gitignore
    • if it doesn't exists then default ignores are used if not instructed to do otherwise
  • optionally send a desktop notification with the exit code from the command
    • requires that the command notify-send is installed
  • optionally clears the screen between executing the command
  • optinally restart the command if it is already executing when a modification is detected
  • optionally watch for metadata changes.
  • sandbox feature which mean that when a process is terminated it also mean that all its children are killed
  • sets the following environment variables in the child process when --env is used:
    • $WATCHEXEC_EVENT is a tuple of values "event type":"path"
    • If multiple files changed then the events are separated by ";"
  • oneshot mode wherein watchexec compare the files on disk to a json database and only execute the command if the files have changed.

Usage Examples

A generic project that must first build the program before the test suite can execute.

$ watchexec -w src --shell -- "make all && make test"

If you are a D developer that wants to execute your tests.

$ watchexech -w source -- dub test

Getting Started

watchexec depends on the following software packages:

It is recommended to install the D compiler by downloading it from the official distribution page.

# link
curl -fsS | bash -s dmd

Then you can run watchexec via dub:

dub run watchexec

alternatively you can clone the repo and build it yourself.

git clone
cd watchexec
dub build -b release

Done! Have fun. Don't be shy to report any issue that you find.


This is a basically a re-implementation of watchexec. I had for a long time been using inotifywait in custom bash scripts but the rust version of watchexec where actually better.

  • Joakim Brännström
colorlog, proc, mylib
1.0.1 2024-Mar-26
1.0.0 2022-Jun-15
0.0.15 2021-Oct-12
0.0.13 2021-May-18
0.0.12 2021-May-14
Show all 18 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 37 downloads total

Short URL: