copiousfreetime / launchy

A helper for launching cross-platform applications in a fire and forget manner.
https://github.com/copiousfreetime/launchy
ISC License
778 stars 60 forks source link

Support for WSL: Spaces in cmd path, translate pathname from WSL2 to Windows #143

Closed bmo closed 8 months ago

bmo commented 3 years ago

Would be great to be able to use this when running Ubuntu on Windows using WSL.

When run using the Windows Subsystem for Linux, the default browser may actually be a Windows app, like chrome. The file://// argument may also need to be translated to the Windows pathname.

The path to the exe ($BROWSER) could have spaces in it, so it's probably good to pass it in quotes. An example of the real path to BROWSER on my machine is

/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe

(I believe it's possible for paths on osx to have spaces, too.)

wslpath -w command (exists on Linux distros running on WSL) translates file paths path from WSL to Windows, which is necessary if the BROWSER being invoked is a Windows application.

rubyFeedback commented 2 years ago

Can that work? E. g. to call from within WSL?

I am thinking a bit about WSL1 too. I have not much experience with WSL2 but I suppose it should be possible; I did not try that on windows. Does the above work on windows? I mean the /mnt/ path. (I suppose it should work but I don't know if you can spawn external commands that way on both WSL1 WSL2; if it is just meant for WSL2 then perhaps the title should be changed.)

bmo commented 2 years ago

yes, I use this on one of my development machines all of the time, for example to have Letter Opener gem start a web browser to display an email message.

bmo commented 2 years ago

I haven't put it into a PR (haven't written the tests), however this gets used every day for me:

https://github.com/bmo/launchy/commit/8c3eab8c27464c2b40578fed28943c97eeef82b9

copiousfreetime commented 2 years ago

@snuggs - take look

snuggs commented 2 years ago

@copiousfreetime now have a windows system. Will install WSL and update when finished doing a touch of (personal) research. @bmo @rubyFeedback this is my first time with WSL installed. (And haven't used Windows in a few years). Is there any value in installing WSL 1, then upgrading to 2? Or at this date just go for v2?

Thanks in advance for your patience.

bmo commented 2 years ago

I believe I went straight to WSL2. I am not near my windows machine until next week.

On Apr 17, 2022, at 3:25 PM, Ahmid @.***> wrote:

 @copiousfreetime now have a windows system. Will install WSL and update when finished doing a touch of (personal) research. @bmo @rubyFeedback this is my first time with WSL installed. (And haven't used Windows in a few years). Is there any value in installing WSL 1, then upgrading to 2? Or at this date just go for v2?

Thanks in advance for your patience.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.