Can I open a directory from command line?
Answered
I want to open a directory as a project from command line.
such as
$ /Applications/PhpStorm.app/Contents/MacOS/phpstorm ./
or
$ /Applications/PhpStorm.app/Contents/MacOS/phpstorm /path/to/new/directory
But it fails.
Is there a way to do this?
Thanks.
Please sign in to leave a comment.
Hi there,
I'm not a Mac user .. but as far as I know you should use "Tools | Create Command-line Launcher..." first -- it should create a "pstorm" script/launcher (whatever it's properly called) which you can use to launch your PhpStorm from terminal.
https://www.jetbrains.com/help/phpstorm/2016.2/working-with-phpstorm-features-from-command-line.html?search=command
If it still fails -- please check "idea.log" file (Help | Show Log in...) for possible hints.
Thanks Andriy Bazanov!
That is the way I want to do!
$ git clone http://github.com/foo/bar
$ pstorm .
Then I can open PHPStorm and make it a project.
Really Thanks!
Almost OK but I have a little problem.
I can open a directory when I closed PHPStorm.
But I cannot open a directory when I already opened PHPStorm project.
pstorm command does not open a new tab.
Any ideas?
Thanks.
What's the exact command you're entering while IDE is opened?
There might be an issue with this: https://youtrack.jetbrains.com/issue/IDEA-103537 - for some users IDE won't open another project with a `pstorm` command while IDE is running.
Thank you Dmitry Tronin.
The command is
pstorm .
But it just focuses to PHPStorm.app.
It might be the same issue you told me.
I give up to open a directory from command line.
Thanks!
My friends solve the problem!
Thanks!
@Satoshi's version works for me.
The problem I found with `pstorm` is that `pstorm` would not open another directory if there are already opened project(s). :/
@Phillip
I aliased the open command it really helps me.
such as
Sorry, but the suggested solution stopped working after upgrade to macOS Catalina. Before it was working fine. Any suggestions?
I'm using Catalina, and still use it all the time. However, I'm using Intellij now:
$ alias op
op='open -a IntelliJ\ IDEA'
Philip Z your suggestion did not work for me either.
Sorry, I should provide more context in my original question:
- I`m on macOS Cataline, version 10.15.5
- I`m using JetBrains Toolbox App, version 1.17.7018 (https://www.jetbrains.com/toolbox/app/), but not a standalone installation
- PhpStorm version is 2020.1.2
I was trying to link `~/Library/Application\ Support/JetBrains/Toolbox/apps/PhpStorm/ch-0/201.7846.90/PhpStorm.app` into `/Applications/PhpStorm.app`. But that did not work.
Eventially, following command worked out for me:
And that is cool, the only thing i`m considered about is the fact I would need to adjust this alias for further PhpStrom updates. Or is there a more flexible solution in my case?
@Dolgushev Serhey
What about built-in command line launcher? AFAIK the Toolbox App can generate them...
This ticket for example (https://youtrack.jetbrains.com/issue/TBX-4527) say it fixed some stuff... so it should work (sorry, I'm a Windows user that does not use Toolbox App)
Seems like it is indeed something similar to https://youtrack.jetbrains.com/issue/TBX-4527. Andriy Bazanov should I submit a separate ticket for my case?
@Dolgushev Serhey
Accordingly to your 1.17.7018 version (which is newer than 1.17.6802 fix version from the ticket) it should be working. Maybe you just need to regenerate the launcher?..
If it would be me I would comment there in the ticket first providing my info and see what the devs will say. If somehow I get no response in few days or they tell "we need to investigate more" then I would do a new ticket.
Check the idea.log file anyway (Help | Show log in Finder...)
no such thing as sorry or should, any s k
In PhpStorm 2021.2.1 works for me likes Satoshi Kamigaki.
aliased command to open PhpStorm