Execute commands automatically when files are updated.
You will need cargo installed. Make sure you have nightly installed.
rustup update nightly Then install using:
cargo install --git https://github.com/nobriot/re-execute.gitThe command is shortened to rex
The UI looks like this:
You can get started reading the help page: rex -h
By default, any file hidden or gitignored under the directories being watched will not trigger any command execution.
rex [OPTIONS] [COMMAND]...If the command contains the {file} string, it will be replaced by updated
files and one command per updated file will be executed.
If the command contains the {files} string, it will be replaced by
a space separated list of files that were updated, and one command in total will be executed.
Just annouce updated files in your config folder:
rex -f $HOME/.config echo "updated files: {files}"You will have to escape commands with quotes if they contain tokens interpreted
by the shell, e.g. &&:
rex -f ~/Desktop "sleep 6 && echo {file}"Run plantuml every time a puml file is modified in the current directory:
rex -e puml plantuml {file}Build your documentation when a .md or .rst file is updated in the docs/ directory
Using -e md,rst is also valid. Use -e "" to allow files without extensions.
rex -f docs/ -e md -e rst make docsLaunch some tests when you update test files:
rex -f src/ -e py -r 'test' -- pytest -k {file}Pass additional environment variables using the --env with KEY=VALUE format
rex --env FOO=BAR ./assets/file_and_env.sh {file}A non-exhaustive list of parameters for the program:
-q/--quiet: Do not print children's stdout/stderr messages-e/--extension: Specify extensions to allow. Will ignore other extensions. e.g.-e md -e ""for .md and extension-less files-E/--env: Set an env variable for the command, e.g.--env FOO=bar-r/--regex: Add a regex to match filenames with. e.g.-r '^[a-z0-9A-Z]*$'will only match filenames with alphanumerical characters. Note that if a file watch in ina/pathand the updated file iaa/path/a/file, then the second part will be evaluated against the regex, i.e.a/file-R/--ignored_regex: Add a regex that if matches, filenames will be ignored.-t/--time: Print the time when each command was executed-H/--hidden: Include hidden files in the triggers-d/--deleted: Call the commands also with files that have been deleted-a/--abort-previous: Abort previous ongoing command execution when files are updated while the program is running--force-poll: Use polling to get files update events. May be necessary on some machines.
This is just a small program I made for my own fun. If you'd like the more professional tools, look here:
