Created
October 6, 2023 08:28
-
-
Save jupblb/afc7ab9fc491e2ba85e5a7266f407047 to your computer and use it in GitHub Desktop.
Run flutter in terminal with auto refresh (recursive)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euo pipefail | |
# adb reverse tcp:4000 tcp:4000 || true | |
PID_FILE="/tmp/flutter.pid" | |
rm -f "$PID_FILE" | |
# https://stackoverflow.com/a/2173421 | |
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT | |
( | |
sleep 10 | |
while [ ! -f "$PID_FILE" ]; do | |
sleep 5 | |
done | |
echo "Starting watch" | |
while true; do | |
fswatch -ro ./lib --latency 1 --event Updated --event Created --event Removed | \ | |
xargs -n1 -I{} kill -USR1 "$(cat "$PID_FILE")" | |
done | |
) & | |
flutter run --pid-file "$PID_FILE" <&0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment