A simple command-line tool to watch for changes in files and exit the process upon detection.
changing monitors specified paths for file modifications (e.g., saves, deletions). Unlike continuous watchers, it exits with a success code (0) as soon as a change is detected, making it useful for scripts that need to react to changes.
- Uses fsnotify for efficient file system notifications.
- Only the first detected event is reported, then the process exits.
- Supports reading file paths from stdin using
-as a file argument. - The
-verboseflag prints additional information about watched files.
# Requires Go installed
# Installs the latest version from GitHub
go install github.com/balazs4/changingchanging [-verbose] <FILE> [<FILE>]
# where <FILE> can be just `-` which means it reads from stdinwhile changing readme.md; do fmt readme.md; donewhile git ls-files | changing -; do go fmt .; done- On startup, prints the number of watched files:
[ 3 files] wait for changes... - When a change is detected, prints the event type and file name:
[WRITE] readme.md - If
-verboseis set, prints each file as it is added to the watch list:watch readme.md - Exits with code 0 after the first change is detected.
- If an error occurs (e.g., file cannot be watched), prints a message to stderr and continues.
- fsnotify (installed automatically via Go modules)
MIT
balazs4
Note: This readme.md was generated by AI (opencode v0.3.5, model: github-copilot/gpt-4.1), but all code is 100% manually written.