microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
16.91k stars 798 forks source link

Introduce commands / binaries: open and xdg-open #8795

Open vadimkantorov opened 1 year ago

vadimkantorov commented 1 year ago

This will help to open files in default Windows apps for that file extension. Similar commands exist in Mac (open.exe) and in Ubuntu (xdg-open.exe) and are useful to open files in OS's default image viewers or pdf viewers

It can probably be achieved by alias open="cmd.exe /c", but it would be nice if a recommended/tested way existed

NotTheDr01ds commented 1 year ago

Agree that it would be nice to have these as built-ins, similar to wslpath.

To be honest, it hasn't been all that important until recently. This functionality is provided out-of-the-box in Ubuntu 20.04 on WSL using the preinstalled wslu package, so most users never noticed it was missing.

However, Ubuntu 22.04, for some reason, has decided not to include the package, even in the repo. And, of course, other distributions could benefit from it as well.

With folks beginning to move to 22.04, though, it's functionality that's going to be "missed" for a majority of users.

It's still possible, of course, to install wslu under most distributions.

At least under Ubuntu (and likely others), it nicely integrates by registering wslview in the Alternatives system for things like www-browser (and others). That means that xdg-open and any Linux app that utilizes it (e.g. Python, Node) will automatically work as well.

And just for reference, most are handled with explorer.exe <file_to_open> rather than cmd.exe.