Last active
November 3, 2022 13:12
-
-
Save aconz2/f78ab70c5ede0043faecbba86b14f2dc to your computer and use it in GitHub Desktop.
simple way to get live reloading browser. Pipe list of filenames that will trigger a refresh (see entr)
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 | |
trap 'kill $(jobs -pr) 2>/dev/null' SIGINT SIGTERM EXIT | |
browser=chromium-browser | |
python3 -m http.server & | |
$browser "http://localhost:8000/$1" 2>/dev/null & | |
browserpid=$! | |
cmd=$(cat <<EOF | |
active=\$(xdotool getactivewindow); | |
for x in \$(xdotool search --onlyvisible --pid $browserpid); do | |
xdotool windowactivate --sync \$x key F5; | |
done; | |
xdotool windowactivate \$active | |
EOF | |
) | |
entr bash -c "$cmd" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment