Last Updated: February 25, 2016
·
3.268K
· jhickner

Reload current browser tab from the terminal

I use this script in conjunction with my file watching tool Hobbes to reload the current browser tab whenever I save the file I'm working on.

Just save this as a shell script and run it from the terminal (or in my case, iTerm). It will reload the current tab in Chrome then refocus the terminal.

#!/bin/sh
exec <"$0" || exit; read v; read v; exec /usr/bin/osascript - "$@"; exit

-- the above is some shell trickery that lets us write the rest of
-- the file in plain applescript

tell application "Google Chrome"
  activate
  tell application "System Events"
    tell process "Google Chrome"
      keystroke "r" using {command down, shift down}
    end tell
  end tell
end tell

tell application "iTerm" to activate

Also in gist form: https://gist.github.com/4081943