Quickly start Browser Sync with Shortcuts on Mac

Apple Shortcuts are so handy. I just use a simple one to start Browser Sync from the menu bar.

I thought I would post it here, as it may be useful for someone.

Just update the proxy IP to suit and make sure to tick “Pin in Menu Bar”

Steps

  1. Create a new shortcut
  2. Add the Run AppleScript action
  3. Copy Paste the code below (add your proxy IP)
  4. Tick the pin to menu box under the details panel
tell application "Terminal"
	do script "browser-sync start --proxy 'http://YOU-PROXY-IP'"
end tell
5 Likes

Without investigating this too much myself, wouldn’t another option be to just tell the webpage to refresh itself?

tell application "Safari"
    tell front document to do JavaScript "window.location.reload()"
end tell

This would remove the need to have browser-sync running.

If browser-sync was better, you could also adapt @PeteSharp ‘s idea as follows…

Instead of adding the Run AppleScript action, there is also a Run Shell Script action. Then you could insert just the browser-sync start --proxy '``http://YOU-PROXY-IP``' bit in there.

Hi @reflex, sure you can run a script to reload the page every time you want to reload it (but why? when you can cmd+r)… but this tip is about Browser Sync, where it automatically reloads on file change and works across a local network. Great workflow (well for me anyway).

My approach to the shortcut, creates a terminal window specifically just for Browser Sync to run in, handy if you have an existing terminal open.

Ohhhh. Now I’m understanding. I thought your script was to tell browser-sync to do an update. Which I didn’t understand (since it’s supposed to do as you just said). I don’t use it myself.

So now I see that you were creating a script to launch the process, not refresh it. :disguised_face:

1 Like

And here I was thinking “start browser sync” explained it :laughing: :grinning_face_with_smiling_eyes:

Indeed – as in “tell the browser to sync”. :face_with_hand_over_mouth:

Anyhoo, the shell command shortcut might be useful, rather than calling AppleScript to run the shell command.