Skip to content

balazs4/changing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

changing

A simple command-line tool to watch for changes in files and exit the process upon detection.

description

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 -verbose flag prints additional information about watched files.

install

# Requires Go installed
# Installs the latest version from GitHub
 go install github.com/balazs4/changing

usage

changing [-verbose] <FILE> [<FILE>]
# where <FILE> can be just `-` which means it reads from stdin

examples

while changing readme.md; do fmt readme.md; done
while git ls-files | changing -; do go fmt .; done

output and exit codes

  • 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 -verbose is 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.

dependencies

  • fsnotify (installed automatically via Go modules)

license

MIT

author

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.

About

A simple command-line tool to watch for changes in files and exit the process upon detection.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Contributors

Languages