do arbitrary command when observed files have changed
Shell
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
README.md
observe-file

README.md

[[meta title="observe-file - do arbitrary command when observed files have changed"]]

NAME

observe-file - do arbitrary command when observed files have changed

SYNOPSIS

observe-file -c COMMAND ( FILE | DIR ) [ ( FILE | DIR ) ... ]

observe-file -x FILE

OPTIONS

  • -c COMMAND

Do command COMMAND when following files have changed.

You can also specify directory name to observe files in directory recursively.

  • -x FILE

observe FILE and do FILE.

This is equivalent:

observe-file -c I<FILE> I<FILE>

EXAMPLES

edit and run simple script

observe-file -x ./foo.pl

observe-file -c "perl -wcT ./foo.pl && ./foo.pl" ./foo.pl

build and run automatically

observe-file -c "make myprog && ./myprog"  myprog.c myprog.h libfoo.c

observe-file -c "make myprog && ./myprog"  src/

reload Firefox when contents have changed

observe-file -c "reload-firefox localhost"  *.html *.css *.js

observe-file -c "deploy && reload-firefox mymacbook"  webapp/

"reload-filefox" is simple shell script to request Firefox with MozRepl.

#!/bin/sh
[ $# -eq 1 -o $# -eq 2 ] || { echo 'usage: reload-firefox HOST PORT'; exit 1; }
host=$1
port=${2:-4242}


echo "reload: $host:$port"
cat <<EOF | nc $host $port
content.location.reload(true)
repl.quit()
EOF
echo

REPOSITORY

http://github.com/hirose31/observe-file

COPYRIGHT & LICENSE

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.