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.

8 comments
Comment actions Permalink

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.

  • "pstorm ." -- this should open PhpStorm and open (or create if does not exist) project in current folder (that pstorm script should expand "." into full path and launch PhpStorm with full path as argument
  • "pstorm /full/path/to/some/dir" -- this should open PhpStorm and open (or create if does not exist) project in that specific folder

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.

6
Comment actions Permalink

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!

0
Comment actions Permalink

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.

2
Comment actions Permalink

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.

0
Comment actions Permalink

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!

1
Comment actions Permalink

My friends solve the problem!

$ open -a IntelliJ\ IDEA\ 15 ./

or

$ open -a PhpStorm ./

 

Thanks!

9
Comment actions Permalink

@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). :/

1
Comment actions Permalink

@Phillip

I aliased the open command it really helps me.

such as

 $ alias op='open -a PhpStorm'
$ git clone https://github.com/yousan/dotfiles
$ op dotfiles

   

 

1

Please sign in to leave a comment.