Merge branch 'v1.1'
fix: don't canonicalize path
Merge branch 'v1.1'
A simple and easy to use tool to run command when files change.
Easywatch is meant as an alternative to inotifywait
or entr
, but has
deliberately as little options as possible and does not require writing
complicated scripts. It is based on Notify library.
Run with the command specified after double hyphen --
to recursively watch
all files in the current directory:
ewatch -- make
-f/--format
You can specify one or more glob patterns to filter files with, using option
-f
or --format
:
ewatch -f '**/*.mklx' -- make
-p/--path
By default current directory is watched. To watch a different directories
and/or single files pass an option -p
or --path
:
ewatch -p 'document.mklx' -p 'text/' -f '**/*.mklx' -- make
EWATCH_FILE_PATH
environment variableEasywatch passes down to the command the EWATCH_FILE_PATH
environment
variable which contains a path to the changed file:
cat >hello_file.sh <<'EOF'
#!/usr/bin/env sh
echo "Hello $EWATCH_FILE_PATH!"
EOF
chmod +x hello_file.sh
ewatch -f '*.txt' -- ./hello_file.sh &
touch test.txt
# Hello <working directory>/./test.txt!
Easywatch can be built by calling cargo build --release
. It will generate
the easywatch
binary in target/release
directory. A symbolic link can then
be created in some directory that is available in the $PATH
. In my case it
is ~/local/.bin
:
ln -s "<easywatch repo>/target/release/easywatch" ~/local/.bin/ewatch