-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: open URL in browser on WSL (#128)
Here's a more elegant solution for opening URLs from WSL in your favorite browser. It is based on `sensible-browser` which is included in the default distribution for WSL. This avoids issues with the WSL environment, `cmd.exe`. quoting parameters, etc. In WSL, set the default browser using the `BROWSER` variable, for example, ```sh export BROWSER="/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe" or export BROWSER="/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe" ``` Note: To permanently set the default browser, add the appropriate entry to your shell's RC file, e.g. .bashrc or .zshrc. To launch a URL from the WSL command line: ```sh sensible-browser https://google.com ``` To launch a URL using `promise-spawn`: ```js const promiseSpawn = require('@npmcli/promise-spawn') promiseSpawn.open('https://google.com') ``` Replaces #118 Closes #62 ### Test ``` os: 5.15.153.1-microsoft-standard-WSL2 node: 20.18.0 npm: 10.8.2 ``` ![image](https://github.com/user-attachments/assets/899801c5-6f05-477e-92c7-f2669526fa03) --------- Co-authored-by: Gar <wraithgar@github.com>
- Loading branch information
Showing
2 changed files
with
59 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters