Skip to content

Instantly share code, notes, and snippets.

@gurgeous
Created September 24, 2022 15:48
Show Gist options
  • Save gurgeous/1750c02e945fe222fa703694822fcfac to your computer and use it in GitHub Desktop.
Save gurgeous/1750c02e945fe222fa703694822fcfac to your computer and use it in GitHub Desktop.
reload a chrome tab when a file changes
#
# Reload localhost tabs. Sample usage:
#
# $ brew install watchexec
# $ watchexec --watch <DIRNAME> reload.osa
#
tell application "Google Chrome"
set window_list to every window
repeat with the_window in window_list
set tab_list to every tab in the_window
repeat with the_tab in tab_list
if (URL of the_tab contains "localhost") then
tell the_tab to reload
end if
end repeat
end repeat
end tell
set t to (time string of (current date))
copy (t & ": reloaded") to stdout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment