Skip to content

Cross-platform way to run arbitrary commands when files change

Notifications You must be signed in to change notification settings

mauri870/iowatch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

iowatch

Cross platform way to run arbitrary commands when files change.

Installation

Download one of the prebuilt binaries from the relases page or install it with cargo:

cargo install --git https://github.com/mauri870/iowatch

Usage

Download a prebuilt binary from the releases page or follow the compilation steps.

iowatch command

Example:

touch /tmp/file.txt
echo /tmp/file.txt | iowatch -p echo "> file changed!"

# in another terminal...
echo 'that is a new line' >> /tmp/file.txt

Note: iowatch has builtin support for .[git]ignore files ;)

For commands that uses builtins, pipes or output redirection that needs to run in a shell, there's a -s flag that uses the default system shell:

find /tmp -type f -name "/tmp/*.txt" | iowatch -s "echo Hello | rev"

It also watch changes recursively if a directory is provided!

echo "dir/to/watch" | iowatch -R echo '!'

A real world use case for example is the linting of a project with hot reload:

echo "./src" | iowatch -R yarn run lint

Or hot reload of a Go project:

echo $PWD | iowatch -R go run .

Or auto compile a Latex project whenever an important file changes:

find . -type f \( -name "*.tex" -o -name "*.bib" -o -name "*.png" \) | iowatch tectonic paper.tex

Compilation

cargo build --release

For arch linux users:

makepkg -sif

About

Cross-platform way to run arbitrary commands when files change

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published