Guard is a command line file watcher.
It watches files you specify in a Guardfile, and runs various actions when they are modified. Best of all, it's very easy to add your own actions.
Setup
- Install gem 'guard'
- Install gems for file-watching / notification(OS specific)
- Create a Guardfile
- Run 'guard' in a terminal and wait...
Guardfile
To configure your guard-watch, you create a Guardfile. A skeleton of this file is auto-generated for you using this command:
$ guard init Guardfile
The commands in the Guardfile consist of three main parts:
- Guard
- Defines a 'guard'... which is a set of files + action to take on change
- Give it a block
- Inside that block, define your watchers
- Watch
- Which files to watch
- Use globs and regexp
- Group
- Useful if you want to trigger different groups of guards in different terminals, or only run some
Example of running just guards in group 'Infra'
$ guard --group Infra
Guard Actions
Guard takes care of the file matching, and watching, then you use plugins to pull in actions to take. Some examples of these include:
Example: Bundler
Install 'guard-bundler' gem...
Then, auto run 'bundler' when the Gemfile changes
Example: Annotate
Install gem :guard-annotate
Then, run 'annotate' task when schema changes
Example: SASS
Install gem :guard-sass
Signal handlers
Signal handlers are used to interact with Guard:
Ctrl-C - Calls each guard's :stop method in order then quits Guard itself
Ctrl-\ - Calls each guard's run_all method in order
Ctrl-Z - Calls each guard's :reload method in order
You can read more about configuring the signal keyboard shortcuts on the github wiki, and home page:
https://github.com/guard/guard
Checkout the Available Guards including:
- guard-annotate by Craig P Jolicoeur
- guard-bundler by Yann Lugrin
- guard-chef by James OKelly
- guard-coffeescript by Michael Kessler
- guard-compass by Olivier Amblet
- guard-cucumber by Michael Kessler
- guard-delayed by David Parry
- guard-ego by Fabio Kuhn
- guard-gimli by Fredrik Wallgren
- guard-jammit by Pelle Braendgaard
- guard-haml by Immanuel Häussermann
- guard-jasmine-headless-webkit by John Bintz
- guard-jstd by arailsdemo
- guard-krl by Michael Farmer
- guard-mozrepl by Phil Hofmann
- guard-less by Brendan Erwin
- guard-livereload by Thibaud Guillaume-Gentil
- guard-markdown by Darren Wallace
- guard-minitest by Yann Lugrin
- guard-nanoc by Yann Lugrin
- guard-passenger by Fabio Kuhn
- guard-phantomjs by Klaus Hartl
- guard-pow by Thibaud Guillaume-Gentil
- guard-prove by Marian Schubert
- guard-pusher by Klaus Hartl
- guard-rails by John Bintz
- guard-rspec by Thibaud Guillaume-Gentil
- guard-shell by Joshua Hawxwell
- guard-soca by Luke Amdor
- guard-spork by Thibaud Guillaume-Gentil
- guard-sprockets by Aaron Cruz
- guard-stendhal by Josep Mª Bach
- guard-test by Rémy Coutable
- guard-uglify by Aaron Cruz
- guard-webrick by Fletcher Nichol