Skip to content

Instantly share code, notes, and snippets.

@jgrodziski
Last active April 21, 2024 01:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgrodziski/cf1c4087c02396f796646b247598769f to your computer and use it in GitHub Desktop.
Save jgrodziski/cf1c4087c02396f796646b247598769f to your computer and use it in GitHub Desktop.
Automatic live reload of browser page after file(s) change
#!/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
#!/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