Is it possible to open PHPStorm from WSL using pstorm command?
I'm trying out WSL2 on Windows 10 and I'd like to have the same behavior as on a macOS, where in the terminal I can type pstorm . and it will open the current folder in the PhpStorm.
Is this possible?
Please sign in to leave a comment.
I doubt that it is even possible in Windows 10 + WSL as the Windows command line does not support UNC paths.
However, it is still possible to use a generated shell script and open project by specifying the full path, like:
Or you may map your WSL network share to a drive letter and then use the launcher in the same way as on macOS.
You can probably write a custom script/alias and use the wslpath command to map paths:
I've just tried this and it actually worked:
Whether it's reliable or not, that's something I don't know.
You can do this with Toolbox and a shell function.
First set up the Toolbox scripts.
Now that the Toolbox scripts are setup you can run the following from the command prompt. The first argument is the path to to the project directory.
Or a WSL project
To be able to run this form WSL you can use the following...
Note: this requires that you mount the C: drive in WSL if you have not already done so.
You can then call this function from your shell...
If no path is specified, it will use your working directory by default. So you could just call...
Thanks for the detailed description of how to achieve this. I don't have the Toolbox, instead I've set up the alias like Álvaro González mentioned
The only issue I have is that it will open two phpstorm windows - one with the correct project opened, and another LightEditProject called `wsl.localhostUbuntu-201.04pathtoproject`.
Not really sure why, but I just close the second one and it does the trick :)
That second project is pretty strange. I have no idea why that happens.
I would strongly recommend getting Toolbox. I didn't when I first started using JetBrains IDEs, and after I started, it is hard to imagine going back. I also use about four different IDEs every week. Toolbox helps keep my IDEs up to date and my projects easily accessible. I am defiantly a fan.
This https://www.jetbrains.com/toolbox-app/ ?
I'm only using PhpStorm from JetBrains, but I'll check it out 👍🏼
Yes. That is the one. I use it a lot to open existing projects. It is faster than starting an one of the IDEs and switching to that project with File > Open Recent. It is a little more point and click than opening a project from the terminal, but it is really convenient. I also use the browser extension to clone a Github repo down to my machine as a new project.
Actually you can do it via running
To make use of an alias like 'pstorm' or 'phpstorm' you can create an alias in your Linux. I myself have Ubuntu 20, so I put text
at the end of my
file.
So, right now I can do
in my project's folder, and my PHPStorm pops up. Enjoy 🙂
For anyone wanting a more up-to-date solution without any errors in the command line, I found this:
https://laracasts.com/discuss/channels/general-discussion/correct-launch-of-phpstorm-from-wsl-in-the-console#reply-904805