I’m using VScode frequently on a remote machine using SSH, not in Development Containers or GitHub Codespaces, just SSH. I recently noticed, that using playwright in VScode automatically opens the html-report of my tests in the browser on my local machine, instead of making me manually go to a URL or do port forwarding (which VScode fortunately also automatically does for you!)

This apparently works because VScode configures the $BROWSER variable to a shell script that can take a URL and open it in the local browser.

When trying out OpenAI Codex on a remote machine, I couldn’t log in because it tried using xdg-open to open a URL. I didn't have that installed and wanted it to behave the same way as playwright does. In order to fix this, you can create an xdg-open shim and make it open links using VScode in your local browser.

  • create this file: /usr/local/bin/xdg-open
  • make it executable: chmod +x /usr/local/bin/xdg-open

Now, any scripts and programs that use xdg-open will open in your local browser when executed from VScode. Woohoo!