Skip to content

Latest commit

 

History

History
39 lines (26 loc) · 1.25 KB

README.org

File metadata and controls

39 lines (26 loc) · 1.25 KB

watch-and-run

Watch a dir and run a given command on changes.

Example

File synchronization

I’ve found a few good use cases for the script so far. One is when your workflow is detached, i.e. for some reason you want to edit your files locally, but always have them syncronized on a remote server.

For these purposes my goto tool is the venerable rsync:

watch-and-run rsync -Pa --delete ~/some/dir remote.server:/remote/dir

Automatic recompilation/re-make

When developing it’s quite handy to run a kind of continous integration. While continous execution of unit tests inside an IDE is probably preferable, this provides a pretty decent alternative.

E.g. when I play around with developing Puppet modules, I might start the program with the following command:

BACKGROUND=1 DIR=~/projects/puppet watch-and-run make ubuntu

In the above we define that we want to

  • start the process in the background,
  • watch ~/projects/puppet
  • run make ubuntu on change

For Puppet development this works nicely with docker-compose from the puppet-in-docker-examples repo.