2

I'm in a Windows Subsystem for Linux (WSL) Ubuntu 20.04 LTS.

My ~/.zshrc file currently has the following appended to the end of the file.

export BROWSER='/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe

When I try to run

xdg-open .

It fails to open the current working directory because the current browser is not compatible.

When running xdg-open ., I expect as if my ~/.zshrc uses:

export BROWSER="powershell.exe /C start"

But only in the case where xdg-open is used. I would like to use brave.exe for all other cases as my default browser.

What is the best way to achieve the above?

1 Answer 1

2

xdg-open is typically for X applications. As far as I know, there's not going to be a way to get it to understand and launch a Windows executable such as Brave.

Many WSL distributions, including Ubuntu 20.04 when installed from the Store, include the wslview command as an alternative for opening the default Windows applications. For others who may be on different distributions, if it isn't available by default, it can be installed as part of the wslu package.

wslview . will open the directory in whatever application Windows would normal use for directory browsing. This would typically be explorer.exe, but in my case I use Directory Opus instead.

I'm not sure how exactly you would override the default directory browser for Windows, though. If Brave isn't set up to do this when you run start . from PowerShell or CMD, I don't think it's going to work for wslview either. See this question for more details on that aspect.

If all else fails, you should always be able to create an alias (or better, shell function) that calls Brave on a path.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .