Skip to content

Run a command upon any change to files in a given directory

License

Notifications You must be signed in to change notification settings

runejuhl/watch-and-run

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

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.

About

Run a command upon any change to files in a given directory

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages