andytwoods

engineer psychologist

IDE+browser-refresh hotkey productivity tip

Jan. 11, 2022

productivity
browser_refresh.jpg

Do you have your IDE and your browser open side-by-side? Do you want explicit control of when your browser refreshes with a single shortcut key? Auto-reloaders are cool but sometimes you need to preserve your browser-state whilst debugging. Opensource to the rescue!:

Windows

AutoHotkey makes this easy. I’ve assigned my F2 key to refresh my currently open tab in Chrome (irrespective of whether or not I am currently working in Chrome), using this script. I've adapted this script from elsewhere but have yet to find the source.

Mac

HammerSpoon is really powerful (just make sure to give it accessibility permissions, eg.). The LUA below script identifies the currently frontmost app and notes it down. It then changes focus to Chrome (opening Chrome if it’s not open; you can change browsers by changing ‘Google Chrome’ ), waits a second for this to happen, and refreshes the browser. It then changes focus back to your IDE.

Return to blog