How to open a directory in PHPStorm or IntelliJ (or any JetBrains IDE) from the command line?

Command LineIntellij IdeaPhpstorm

Command Line Problem Overview


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.

Command Line Solutions


Solution 1 - Command Line

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

Solution 2 - Command Line

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 .

Solution 3 - Command Line

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

Solution 4 - Command Line

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.

Solution 5 - Command Line

Here is the menu entry for v2016.2:

menu-entry

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

Hope it helps.

Solution 6 - Command Line

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 .

Solution 7 - Command Line

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.


Solution 8 - Command Line

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.

Solution 9 - Command Line

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.

Solution 10 - Command Line

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 .".

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJordan BrownView Question on Stackoverflow
Solution 1 - Command LineAlexView Answer on Stackoverflow
Solution 2 - Command LineRickard KamelView Answer on Stackoverflow
Solution 3 - Command LinerymoView Answer on Stackoverflow
Solution 4 - Command LinevivanovView Answer on Stackoverflow
Solution 5 - Command LineCKIDOWView Answer on Stackoverflow
Solution 6 - Command Linetanner burtonView Answer on Stackoverflow
Solution 7 - Command Linebolec_kolecView Answer on Stackoverflow
Solution 8 - Command Linewired00View Answer on Stackoverflow
Solution 9 - Command LineSerhey DolgushevView Answer on Stackoverflow
Solution 10 - Command LineAvat RezaeiView Answer on Stackoverflow