Skip to content

Minimalist cross-platform app to watch a directory for changes.

License

Notifications You must be signed in to change notification settings

jdspugh/jp-watch-c

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jp-watch

About

Lightweight, cross platform app to efficiently watch a set of files and/or directories recursively for changes on Linux and MacOS.

File and directory creation, deletion and attribute changes are reported. Output is one absolute path per line e.g.:

/home/user/new-file
/home/user/new-dir/
/tmp/file5349872

Installation

MacOS

$ cd ~
$ git clone https://github.com/jdspugh/jp-watch-c.git
$ cd jp-watch-c
$ clang -O3 -framework CoreServices -o jp-watch jp-watch.c
$ sudo mv jp-watch /usr/local/bin
$ jp-watch --help

Linux

$ cd ~
$ git clone https://github.com/jdspugh/jp-watch-c.git
$ cd jp-watch-c
$ gcc -O3 -o jp-watch jp-watch.c
$ sudo mv jp-watch /usr/local/bin
$ jp-watch --help

Examples

Watch the local directory

$ jp-watch .

Watch the whole drive

$ jp-watch /

Watch a few different files and directories with a combination of relative and absolute paths

$ jp-watch README.md jp-watch.c /var/www /tmp

Limitations

jp-watch is not designed to watch a large number (hundreds or thousands) of different directories. The more files and directories you pass as parameters, the more cpu and memory the app will consume with a difficulty of O(1). It would be better to watch the containing directories of the files and directories you want to watch instead.

Articles

Read my blog post for the full details on this tools, it's design and implementation.

Special Thanks to

Code Review Stack Exchange