This little addition (1 proper line of code!) to guard allows you to run shell commands when certain files are altered.
Make sure you have guard installed.
Install the gem with:
gem install guard-shell
Add it to your Gemfile:
gem 'guard-shell'
And then add a basic setup to your Guardfile:
guard init shell
If you can do something in your shell, it is probably very easy to setup with guard-shell, here are a few examples.
guard 'shell' do
# create a copy of the file with '.backup' at the end
watch('(.*)') {|m| `cp #{m[0]} #{m[0]}.backup` }
end
guard 'shell' do
watch('.*') { `git st` }
end
guard 'shell' do
# builds latex file to pdf and hides output
watch('(.*).tex') do |m|
`pdflatex -shell-escape #{m[0]} 1>/dev/null`
puts "built #{m[1]}.pdf"
end
end
guard 'shell' do
watch('(.*)') {|m| `say #{m[0]}` }
end