watcher
This commit is contained in:
24
watch.sh
Executable file
24
watch.sh
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
run_converter() {
|
||||
bash ./convert-md.sh
|
||||
}
|
||||
|
||||
python3 -m http.server 8000 &
|
||||
SERVER_PID=$!
|
||||
|
||||
cleanup() {
|
||||
echo "Stopping server (PID: $SERVER_PID)..."
|
||||
kill $SERVER_PID 2>/dev/null
|
||||
exit 0
|
||||
}
|
||||
trap cleanup SIGINT SIGTERM
|
||||
|
||||
run_converter
|
||||
|
||||
inotifywait -m -e modify -e create -e delete --include '\.md$' -r . 2>/dev/null | while read -r path event file; do
|
||||
echo "Change detected: $event on $path$file"
|
||||
run_converter
|
||||
done
|
||||
Reference in New Issue
Block a user