reflex

Run commands when files change

TLDR

Watch and run command
$ reflex [command]
Watch specific pattern
$ reflex -r '\.go$' [go build]
Watch directory
$ reflex -d [src/] [command]
Multiple patterns
$ reflex -r '\.go$' -r '\.html$' [command]
Start without initial run
$ reflex -s [command]
Decoration mode
$ reflex -d [.] -- [sh -c "echo changed"]
Exclude pattern
$ reflex -r '\.go$' -R 'vendor/' [command]

SYNOPSIS

reflex [-r regex] [-d dir] [-R exclude] [options] command

DESCRIPTION

reflex watches files and runs commands on changes. It's a flexible file watcher for development.Regex patterns filter which files trigger. Multiple patterns combine for complex matching.Service mode runs a long-running process. The process restarts on changes.Exclusions ignore vendor directories or build output. Prevents unnecessary rebuilds.Configuration files define complex watch rules. Multiple watchers in one file.

PARAMETERS

-r REGEX

Include pattern.
-R REGEX
Exclude pattern.
-d DIR
Watch directory.
-s
Start service (no initial run).
-g GLOB
Glob pattern.
-c CONFIG
Config file.
--all
Match all files.
--decoration MODE
Output decoration.

CONFIGURATION

.reflex

Project-level configuration file defining watch rules, one per line, with regex patterns and commands. Loaded automatically when present in the current directory.

INSTALL

sudo apt install reflex
sudo apk add reflex
brew install reflex
nix profile install nixpkgs#reflex

CAVEATS

Polling fallback on some filesystems. Rapid changes may batch. Initial run may not be wanted.

HISTORY

Reflex was created as a simple, flexible file watcher. It focuses on development workflow automation with minimal configuration.

SEE ALSO

entr(1), watchman(1), fswatch(1), inotifywait(1)