Skip to content

sharkdp/trigger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 

Repository files navigation

trigger

Usage: trigger COMMAND [FILE...]

trigger runs the given COMMAND every time one of the FILEs is changed. If no FILE argument is given, trigger watches everything in the current directory, recursively.

In the COMMAND string, #1, #2, .. can be used as synonyms for the FILEnames. The helper tg COMMAND FILE ... is a shortcut for trigger 'COMMAND #1' FILE ....

Example usage

Examples

Make

Run make every time one of the files in the current directory changes:

trigger make

Python

Run python main.py every time either main.py or config.py changes:

trigger 'python #1' main.py config.py

By using the tg helper command, this can be shortened to:

tg python main.py config.py

Markdown to PDF

Convert a Markdown document to PDF every time it is changed. Combine this with an auto-reloading PDF-viewer (e.g. okular) to get a live preview:

tg 'pandoc -t latex -o README.pdf' README.md

Less to CSS

Convert a LESS file to CSS:

trigger 'lessc #1 > main.css' main.less

Interrupt mode

If trigger is called with the -i (or --interrupt) option, it will kill running subprocesses whenever a file changes:

trigger -i longRunningCommand input.dat

Requirements

trigger is just a simple wrapper around inotifywait. It should be available for most Linux distributions (the package is typically called inotify-tools).

Installation

Keeping in mind that, in principle, you should not copy-and-paste into your shell, something like this should work:

git clone https://github.com/sharkdp/trigger ~/.trigger

echo 'export PATH="$PATH:$HOME/.trigger"' >> .bashrc

Related projects

Also have a look at these projects, to see if they fit your needs better:

About

Run a user-defined command on file changes

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Languages