https://github.com/gartisk/watch-and-prefix
222
Watches a
.envfile and writes a VAR-prefixed copy on every save.
Whenever you save the watched file, watch-and-prefix reads each variable line and prepends your chosen prefix — then writes the result to the destination you configured.
Blank lines, comments, and lines that already carry the prefix are left untouched (idempotent).
| Flag | Required | Description |
|---|---|---|
--file <FILE> | ✅ | Path to the file to watch |
--var-prefix <PREFIX> | ✅ | Prefix prepended to every variable line (e.g. HOMEPAGE_VAR_) |
--output <PATH> | ✅ (unless --overwrite) | Destination — see the three forms below |
--overwrite | optional | Modify the source file in place. Mutually exclusive with --output |
--output path forms| Form | Example | Result |
|---|---|---|
Directory (trailing /) | --output /out/ | Saves inside /out/ keeping the original filename |
| Full path | --output /out/prefixed.env | Saves as that exact file |
| Bare filename | --output prefixed.env | Saves next to the source file |
Requires bash and inotify-tools (sudo apt install inotify-tools on Debian/Ubuntu).
# Save with a custom name into a specific folder
./watch-and-prefix.sh \
--file config.env \
--var-prefix HOMEPAGE_VAR_ \
--output /tmp/output/homepage_config.env
# Save into a folder, keep the original filename
./watch-and-prefix.sh \
--file config.env \
--var-prefix HOMEPAGE_VAR_ \
--output /tmp/output/
# Bare filename — saved next to the source file
./watch-and-prefix.sh \
--file config.env \
--var-prefix HOMEPAGE_VAR_ \
--output prefixed.env
# Overwrite the source file in place (no separate output file)
./watch-and-prefix.sh \
--file config.env \
--var-prefix HOMEPAGE_VAR_ \
--overwrite
compose.local.yaml)Builds the image straight from the local Dockerfile — no Docker Hub account needed.
# Build and run (foreground)
docker compose -f compose.local.yaml up --build
# Build and run (detached / background)
docker compose -f compose.local.yaml up --build -d
# Follow logs after detaching
docker compose -f compose.local.yaml logs -f
# Stop
docker compose -f compose.local.yaml down
Edit the command: block inside compose.local.yaml to change the file, prefix, or output path.
compose.yaml)Uses a pre-built image from Docker Hub. Create a .env file at the project root:
DOCKER_USERNAME=gartisk
IMAGE_NAME=watch-and-prefix
IMAGE_TAG=latest
Then:
# Pull and run
docker compose up
# Detached
docker compose up -d
# Stop
docker compose down
docker run)No compose file needed — useful for quick tests or CI.
# Save with a custom name
docker run --rm \
-v ./input:/watch/input:ro \
-v ./output:/watch/output \
your_dockerhub_username/watch-and-prefix:latest \
watch-and-prefix.sh \
--file /watch/input/config.env \
--var-prefix HOMEPAGE_VAR_ \
--output /watch/output/homepage_config.env
# Overwrite in place (only one volume mount needed)
docker run --rm \
-v ./input:/watch/input \
your_dockerhub_username/watch-and-prefix:latest \
watch-and-prefix.sh \
--file /watch/input/config.env \
--var-prefix HOMEPAGE_VAR_ \
--overwrite
Content type
Image
Digest
sha256:164f87a4a…
Size
4 MB
Last updated
7 months ago
docker pull gartisk/watch-and-prefix