Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto browser refresh during web development

It is well and good that the server restarts automatically for each change in the code. How would you have even the browser refresh automatically, as per configuration (Turn on and off, the least).

How to do it on Windows, and on Linux, for all different development frameworks.

What existing packages allow you to do it, and if you are to just add a browser.refresh at each runserver, how would you do it.

like image 667
lprsd Avatar asked Feb 23 '26 11:02

lprsd


1 Answers

On Mac OS X you can do that using AppleScript. I did that some time ago and been using it ever since.

# Check if Firefox is running, if so refresh
ps -xc|grep -sqi firefox && osascript <<'APPLESCRIPT'
tell app "Firefox" to activate
tell app "System Events"
   keystroke "r" using {command down}
end tell
APPLESCRIPT

# Check if Safari is running, if so refresh
ps -xc|grep -sq Safari && osascript -e 'tell app "Safari"' -e 'activate' \
-e 'do JavaScript    "window.location.reload();" in first document' -e 'end tell'

It refreshes Safari and Firefox, but as I said, it only works the mac. I've been using it on Textmate, this way every time I save a django file I also refresh the browsers. Pretty handy, but also slightly annoying when reading docs online and writing code, hehe.

like image 113
Edu Felipe Avatar answered Feb 24 '26 23:02

Edu Felipe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!