MyNixOS website logo
Description

A compact file system watcher for Mac OS X, Linux and Windows.

Spy can be used to watch for file changes and to either report the modified files or run a command if files change. It can be used to trigger compilation, to run tests or start a deployment.

Spy

Spy is a compact file system watcher for Mac OS X and Linux (Note: Should work on Windows but is currently untested).

Usage

Spy expects a single argument, the directory or a single file to watch. Spy currently supports two different modes: watch and run mode. Press CTRL-D to stop watching for file system changes.

Watch mode

In output mode Spy will print the path to a modified file to STDOUT (followed by a newline) whenever a file modification (new file added, file modified, file deleted) occurs.

$> spy watch .
path/to/modified/file

Because watch is the default mode you can omit the watch command if you want:

$> spy .

It's possible to watch a single file (this obviously only shows changes to that particular file):

$> spy /path/to/file

The default format is the full path to the modified file followed by a newline. To make it easier to parse the output, the --format=json changes the output to be printed formatted as a JSON object (again followed by a newline).

$> spy watch --format=json .
{"path":"/path/to/modified.file","flag":"Added","time":"2012-12-20 11:26:56.859456 UTC"}

Flag is one of "Added", "Modified", "Removed".

For directories the following options apply:

An optional second argument can be used to filter the files in the given directory using a glob pattern:

$> spy watch /path/to/directory "*.md"

Run mode

In run mode Spy will execute a given command whenever a file modification occurs without printing modifications to stdout. The command will be executed with the path to the modified file as the last argument.

$> spy run "./run-build.sh"

In the example above the shell script run-build.sh would be executed with the path to the modified file as the first argument.

If the command to be executed does not expect any (additional) arguments the --notify-only flag can be used. This will cause spy to execute the command without passing the path as an argument:

$> spy run --notify-only "rake test" .

To compile Spy for example use:

$> spy run -n "cabal build" src

Installation

Binary distribution

The binary distribution contains a 64bit binary compiled for Mac OS X or Linux.

Download the tarball from https://bitbucket.org/ssaasen/spy/downloads and run "make install" to copy the binary and the man page into the correct target directories:

$> curl -OL https://bitbucket.org/ssaasen/spy/downloads/spy-PLATFORM-ARCH-VERSION.tar.gz
$> tar xfz spy-PLATFORM-ARCH-VERSION.tar.gz
$> cd spy
$> make install

The user manual should now be available via man spy and the spy executable should be on your $PATH.

Homebrew on Mac OS X?

You can use:

brew tap juretta/spy
brew install spy

To install the latest spy release.

Source distribution

You need the Haskell platform installed and cabal-install available on your $PATH.

To install spy from hackage simply run:

$> cabal install spy

Done!

To install spy from git you need the Haskell Tool Stack installed and stack available on your $PATH:

$> [email protected]:ssaasen/spy.git
$> cd spy
$> stack install
Metadata

Version

0.14

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows