67

Is there a way to open up a directory in PHPStorm or an equivalent Jetbrains IDE from the command line? For example, in Textmate, I would just do:

mate .

to open the working directory.

Makoto
  • 104,088
  • 27
  • 192
  • 230
Jordan Brown
  • 13,603
  • 6
  • 30
  • 29

12 Answers12

124

Use Tools -> Create command line launcher and then you can execute pstorm .

Alex
  • 32,506
  • 16
  • 106
  • 171
56

Here's how I got IntelliJ Command-line launcher to work with MAC Sierra (v 10.12.2).

This works with IntelliJ IDEA:

  1. Tools -> Create Command-line Launcher.. enter image description here
  2. Replace 'idea' in the string '/usr/local/bin/idea' with whatever you wish.
    enter image description here (I use 'ij'), so for me its '/usr/local/bin/ij'.
  3. Open your terminal
  4. Navigate to the project/folder you want to open.
  5. Write the chars you wrote after 'bin/' and then '.' enter image description here

    For me its ij .

Rickard Kamel
  • 570
  • 4
  • 5
10

On OS X: open -a 'phpstorm.app' file-or-folder

rymo
  • 3,285
  • 2
  • 36
  • 40
6

For PhpStorm on Windows:

  1. Add the PHPStorm's installation path to the Environment Variables "PATH" variable,

  2. Scroll to the project folder in the command line

  3. Issue the command phpstorm64.exe . if it is 64 bit machine or phpstorm.exe . for 32 bit machine.

I presume the same strategy will work for IntelliJ as well.

vivanov
  • 1,422
  • 3
  • 21
  • 29
5

Here is the menu entry for v2016.2:

menu-entry

After that you can open folders with pstorm {myfolder}.

Hope it helps.

SND
  • 1,552
  • 2
  • 16
  • 29
CKIDOW
  • 51
  • 1
  • 2
5

On MacOs edit ~./bash_profile add this line

alias pst="open -a 'phpstorm.app'"

Source it

source ~./bash_profile

Now you can open phpstorm in a directory with

pst .
tanner burton
  • 1,049
  • 13
  • 14
5

If you see this message enter image description here

for Intellij 2019.+ please check this answer. It uses Jetbrains toolbox. You just need to set path in Generate shell scripts option to /usr/local/bin/ in Jetbrains toolbox https://stackoverflow.com/a/56050914

and then just run idea . or pycharm . , phpstorm . etc.


bolec_kolec
  • 500
  • 3
  • 13
1

If you are using the JetBrains toolbox, you can configure the shell script for each IDE by going to

  1. settings of the IDE in the toolbox (three dots > settings)

  2. configuration

  3. shell script name

Set it to any text you want

Nithin P M
  • 191
  • 1
  • 7
0

So the method Tools > Create command line launcher... no longer exists in OSX Intellij 2019.1

You can manually make this change via:

vim /usr/local/bin/idea

Change these lines appropriately from old version to new. should be something like this:

RUN_PATH = u'/Users/blahblah/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/191.6183.87/IntelliJ IDEA.app'
CONFIG_PATH = u'/Users/blahblah/Library/Preferences/IntelliJIdea2019.1'
SYSTEM_PATH = u'/Users/blahblah/Library/Caches/IntelliJIdea2019.1'

If you don't know the new path then run something like:

ls /Users/blahblah/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U

or manually navigate via finder, then drag/drop the IntelliJ IDEA.app icon from finder into your cli to copy across the full path.

wired00
  • 13,930
  • 7
  • 70
  • 73
0

I`m using JetBrains Toolbox to get the latest updates. And the only solution which worked for me (macOS) is:

  1. Add the following function into ~/.bash_profile
phpstorm-open-current-path() {
    PHP_STORM_CH=~/Library/Application\ Support/JetBrains/Toolbox/apps/PhpStorm/ch-0
    PHP_STORM_LATEST_VERSION=$(ls -rA1 "${PHP_STORM_CH}" | head -1)
    open -a "${PHP_STORM_CH}/${PHP_STORM_LATEST_VERSION}/PhpStorm.app"
}
  1. Reload the changes by opening a new terminal, or running the following command in the current one:
. ~/.bash_profile
  1. Use it:
cd <PROJECT_DIR>
phpstorm-open-current-path

It should be pretty easy to adopt it for any other IDE/OS.

0

1- add the phpstorm installation path to the path system variable

2- in project folder in address bar type "cmd".

3- in cmd type "phpstorm64 .".

Avat Rezaei
  • 143
  • 9
0

Here's how it did it on macOS:

  1. navigate to /usr/local/bin directory in your terminal
  2. create the file /usr/local/bin/idea. in the terminal paste: sudo vim idea
  3. paste the following into the file (this was pulled from https://www.jetbrains.com/help/idea/working-with-the-ide-features-from-command-line.html#standalone):
#!/bin/sh

open -na "IntelliJ IDEA.app" --args "$@"
  1. save file in vim (esc -> shift + : -> wq! -> enter)
  2. change the file permissions of newly created file: sudo chmod 755 idea
  3. in your terminal, navigate to the code directory you would like to open in intelliJ
  4. type idea . and it should open entire directory in intelliJ

Hope this helps!

Bert
  • 814
  • 1
  • 7
  • 9