Reload current browser tab from the terminal

Posted on

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.

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"
  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:

Leave a Reply

Your email address will not be published.