Last active
April 21, 2024 01:36
-
-
Save jgrodziski/cf1c4087c02396f796646b247598769f to your computer and use it in GitHub Desktop.
Automatic live reload of browser page after file(s) change
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
#!/bin/bash | |
osascript <<EOF | |
tell application "Google Chrome" | |
set windowList to every window | |
repeat with aWindow in windowList | |
set tabList to every tab of aWindow | |
repeat with atab in tabList | |
if (URL of atab contains "$1") then | |
tell atab to reload | |
end if | |
end repeat | |
end repeat | |
end tell | |
tell application "Safari" | |
set windowList to every window | |
repeat with aWindow in windowList | |
set tabList to every tab of aWindow | |
repeat with atab in tabList | |
if (URL of atab contains "$1") then | |
tell atab to do javascript "window.location.reload()" | |
end if | |
end repeat | |
end repeat | |
end tell | |
EOF |
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
#!/bin/bash | |
fswatch -o $1 | xargs -n1 -I{} /usr/bin/env bash -c "echo Reloading $2; ~/bin/reload-browser.sh $2" reload |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment