Files
org_web/watcher.sh
Zaine bb299b2f98
Some checks failed
Build Org Website / build (push) Has been cancelled
gitea runners
2026-05-06 14:55:10 +01:00

24 lines
686 B
Bash
Executable File

#!/usr/bin/env bash
# run a single command once per save in a subfolder
WATCH="/home/zaine/master-folder/org_files/org_web/lima" # subfolder to watch
RUN_IN="/home/zaine/master-folder/org_files/org_web" # run command from here
# pass the command to run as args:
# ./watch.sh emacs -Q --script build-site.el
[[ $# -gt 0 ]] || { echo "Usage: $0 <command to run>"; exit 1; }
CMD=("$@")
# ignore common temp/swap files
EXCLUDE='(^|/)(#.*#|\.#.*|.*~|.*\.tmp|.*\.sw[pox])($|/)'
inotifywait -m -r -q \
-e close_write,moved_to \
--exclude "$EXCLUDE" \
--format 'Triggered by: %w%f' \
"$WATCH" |
while read -r path; do
echo "$path"
( cd "$RUN_IN" && "${CMD[@]}" )
done