In ~/prison, you put the Guardfile that describe which files to watch for changes and what to execute once a file is modified.
guard 'shell' do
watch(%r{^.+\.txt$}) { |m| `echo #{File.join(::Guard.listener.directory, m[0])}` }
endIn ~/watch_from_here, you put the Gemfile that list the guards you want to use.
source "http://rubygems.org"
gem 'rb-fsevent' # OSX
# gem 'rb-inotify' # Linux
# gem 'rb-fchange' # Windows
# Guard is not yet released with the :watchdir and :guardfile options
gem 'guard', :git => 'git://github.com/guard/guard.git'
gem 'guard-shell' # for this example we will use guard-shellIn ~/watch_here, you create a file the_great_escape.txt that you will modify later.
You are ready to test this out!
β cd ~/watch_from_here
β bundle exec guard -watchdir ~/watch_here -guardfile ~/prison/Guardfile
# or
β bundle exec guard -w ~/watch_here -G ~/prison/GuardfileThen modify ~/watch_here/the_great_escape.txt and you should see the file path printed out by Guard!
YOUPI!!!
Protip: I personally use the be alias for bundle exec, but since be guard -w ~/watch_here -G ~/prison/Guardfile is still wayyyyyyy too long, I use another alias bg for bundle exec guard, that's better. And if you like the -clear/-c option of Guard, I also use the bgc for bundle exec guard -c!
This worked great for me, π