Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/joh/when-changed
Execute a command when a file is changed
https://github.com/joh/when-changed
Last synced: 6 days ago
JSON representation
Execute a command when a file is changed
- Host: GitHub
- URL: https://github.com/joh/when-changed
- Owner: joh
- License: other
- Created: 2011-01-31T21:25:52.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2024-04-02T21:02:10.000Z (8 months ago)
- Last Synced: 2024-11-29T18:04:09.769Z (13 days ago)
- Language: Python
- Homepage:
- Size: 62.5 KB
- Stars: 1,216
- Watchers: 21
- Forks: 107
- Open Issues: 18
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-hacking-lists - joh/when-changed - Execute a command when a file is changed (Python)
README
# when-changed: Run a command when a file is changed
### What is it?
Tired of switching to the shell to test the changes you just made to
your code? Starting to feel like a mindless drone, manually running
pdflatex for the 30th time to see how your resume now looks?Worry not, when-changed is here to help! Whenever it sees that you have
changed the file, when-changed runs any command you specify.So to generate your latex resume automatically, you can do this:
```sh
$ when-changed CV.tex pdflatex CV.tex
```Sweetness!
### What do I need?
- Python 2.6+
- watchdog### Installation
```sh
pip install https://github.com/joh/when-changed/archive/master.zip
```### Usage
```sh
when-changed [OPTION] FILE COMMAND...
when-changed [OPTION] FILE [FILE ...] -c COMMAND
```FILE can be a directory. Use %f to pass the filename to the command.
**Options:**
- -r Watch recursively
- -v Verbose output. Multiple -v options increase the verbosity. The maximum is 3: -vvv.
- -1 Don't re-run command if files changed while command was running
- -s Run command immediately at start
- -q Run command quietly### Environment variables:
when-changed provides the following environment variables:
- WHEN_CHANGED_EVENT: reflects the current event type that occurs.
Could be either:
- file_created
- file_modified
- file_moved
- file_deleted- WHEN_CHANGED_FILE: provides the full path of the file that has generated the event.