https://github.com/mauri870/iowatch
Cross-platform way to run arbitrary commands when files change
https://github.com/mauri870/iowatch
entr file-changes rust
Last synced: 10 months ago
JSON representation
Cross-platform way to run arbitrary commands when files change
- Host: GitHub
- URL: https://github.com/mauri870/iowatch
- Owner: mauri870
- Created: 2018-12-27T22:22:20.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-02-12T23:36:21.000Z (over 3 years ago)
- Last Synced: 2024-11-07T19:52:53.790Z (over 1 year ago)
- Topics: entr, file-changes, rust
- Language: Rust
- Size: 104 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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:
```bash
cargo install --git https://github.com/mauri870/iowatch
```
## Usage
Download a prebuilt binary from the releases page or follow the compilation steps.
```bash
iowatch command
```
Example:
```bash
touch /tmp/file.txt
iowatch -f /tmp/file.txt -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:
```bash
find /tmp -type f -name '/tmp/*.txt' | iowatch -s 'echo Hello | rev'
```
It also watch changes recursively if a directory is provided!
```bash
echo "dir/to/watch" | iowatch -R echo '!'
```
A real world use case for example is the linting of a project with hot reload:
```bash
echo "./src" | iowatch -R yarn run lint
```
Or hot reload of a Go project:
```bash
echo $PWD | iowatch -R go run .
```
Or auto compile a Latex project whenever an important file changes:
```bash
find . -type f \( -name "*.tex" -o -name "*.bib" -o -name "*.png" \) | iowatch tectonic paper.tex
```
## Compilation
```bash
cargo build --release
```
For arch linux users:
```bash
makepkg -sif
```
# Tests
We use bats for testing, you can run them with:
```bash
cargo build --release
bats ./tests
```
# Debugging
```bash
RUST_LOG=debug iowatch
```