144

To edit files from terminal I use subl (for sublime text) in order to edit the file; example: If i need to edit app.js file I use subl app.js Is there any way I can set up webstorm to open from the terminal ?

3
  • what is your OS? are you just trying to launch it from the screen? Commented Nov 12, 2014 at 4:29
  • 1
    I am using MAC iOS; I want to launch the webstorm from the terminal. Commented Nov 12, 2014 at 4:30
  • 1
    what about open -a /Applications/Webstorm.app I cannot test right now Commented Nov 12, 2014 at 4:38

18 Answers 18

317
  1. Try in terminal 'wstorm' and 'webstorm'
  2. If the commands don't work you can run in WebStorm: "Tools" -> "Create Command Line Launcher..."

Note: The solution works only for Linux / MacOS

Sign up to request clarification or add additional context in comments.

8 Comments

To open the current directory in webstorm using command line launcher, you can type wstorm .
on Windows its not there, not the command, not the Tools action.
"Tools" -> "Create Command Line Launcher..." verified working on WebStorm 2017.1 on Mac
As of late May 2017 (Webstorm 2017.1.3), wstorm doesn't work, and the command Create Command Line Launcher isn't found under under my Windows Tools dropdown. Help does bring up that command when you search for it under Find Action (and states that it's under Tools), but there's no way to select it.
So interestingly enough my "command line launcher" which I set up with an older version of Webstorm still worked to launch WebStorm, but stopped opening projects (I usually do webstorm . to open the project in the current directory. Anyway, recreating the "command line launcher" fixed this problem. Maybe helpful to people that upgraded.
|
29

Update January 2016 using Webstorm 11.0.3 on mac os x

There was no option as described in the accepted answer.

Instead, just use the already installed command line binary wstorm designed for this purpose. Location shown below:

enter image description here

If you actually wish to open webstorm and have it load the contents of the current working directory for example, then place a . after the command:

wstorm .

Noted, others had made similar comments in this answers section, and wished to clarify the situation.

4 Comments

Seems that if you already have webstorm open all this command will do is just change focus over to webstorm but not actually open the file. Know any workarounds?
@jcollum - hi, sorry for delayed reply. updated answer - have you tried as above?
Nope, still just seeing it change focus to an existing webstorm window.
I am also seeing the behavior @jcollum describes.
23

In Webstorm 2020.1.2 you need to do it via JetBrains ToolBox Settings. To do that go to JetBrain Toolbox, click on the settings cog, open Shell Scripts and type the path: /usr/local/bin click apply. Go to your terminal, from your project folder type webstorm . Hope this helps.

enter image description here

As suggested by Ali Faris(comment below), if you have an error like this Shell Scripts failed: /usr/local/bin/webstorm (Permission denied): inside of the logs Jetbrains Toobox -> settings -> show log files -> toolbox.log (for me in: ~/Library/Logs/JetBrains/Toolbox).

Change /usr/local/bin to another folder name of your choice with the correct access rights, e.g - I chose this name: ~/.jetbrains-launchers.

You can check if script is created by Jetbrains: ls ~/.jetbrains-launchers (you should see a script for each of the jetbrains applications you use).

Add this to your path if needed for example if you use zsh add this at the bottom of your .zshrc export PATH="$HOME/.jetbrains-launchers:$PATH"

Open a new terminal window and this should work.

Basically jetbrains will create script like this (in this case for webstorm cat ~/.jetbrains-launchers/webstorm):

#!/bin/bash
#Generated by JetBrains Toolbox 1.22.10970 at 2022-01-08T12:57:24.803251

declare -a ideargs=()
declare -- wait=""

for o in "$@"; do
  if [[ "$o" = "--wait" || "$o" = "-w" ]]; then
    wait="-W"
    o="--wait"
  fi
  if [[ "$o" =~ " " ]]; then
    ideargs+=("\"$o\"")
  else
    ideargs+=("$o")
  fi
done

open -na "/Users/[YOUR-USER]/Library/Application Support/JetBrains/Toolbox/apps/WebStorm/ch-0/213.6461.79/WebStorm.app/Contents/MacOS/webstorm" $wait --args "${ideargs[@]}"

1 Comment

for anyone that /usr/local/bin didn't work for him, use another location that Toolbox App have permission to create files, for me I chose ~/intellij-launchers
22

Another way to do that:

open -a /Applications/WebStorm.app                      #Open last project
open -a /Applications/WebStorm.app Desktop              #Open particular folder
open -a /Applications/WebStorm.app Desktop myscript.js  #Open particular file

You can add alias to your config file:

#Edit your config:
vim ~/.bashrc
#add line:
alias ws='open -a /Applications/WebStorm.app'
#Read your config file:
source ~/.bashrc

Now you can use it:

ws . myscript.js

1 Comment

Or, since wstorm already does that, you can just set the alias as: alias ws='wstorm'
20

I also downloaded WebStorm and wanted to use a similar shortcut to open files directly from the terminal.

I was surprised to find I already had a shortcut in my command line tools for webstorm:

subl is to Sublime as wstorm is to Webstorm.

Otherwise, as anstarovoyt has kindly pointed out, you can simply create your own shortcut via "Tools" > "Create Command Line Launcher"

1 Comment

After updating, I found that wstorm . opens WebStorm at directory /Applications/WebStorm.app/Contents/bin. This was fixed by rerunning "Create Command Line Launcher".
5

I know this is an older thread, but trying to achieve this using Windows was kind of a pain and I wasn't able to find anything specifically designed for my purposes. I created a Bash function that you can add as an alias (for Git Bash on Windows) that works similar to the command line functions in Visual Studio Code.

Here's the link to the Gist.

If you change the integrated terminal in WebStorm to Git Bash (instructions included in the Gist), you can perform the following actions:

Create a new file in the current working directory and open it in the editor:

wstorm foo.js

Create a new file in an existing relative path and open it in the editor:

wstorm foo/bar.js

This also works with subdirectories that don't exist:

wstorm this/path/doesnt/exist/file.js

If you're working in a Git Bash terminal (not in WebStorm) and want to open WebStorm up in the current directory, you can open it similar to Visual Studio Code:

wstorm .

Note: This needs to be done in a directory with a .idea folder.

2 Comments

can we trigger run or debug using CLI?
I did some cursory research and it looks like that isn't possible.
5

After setting up WebStorm to create the cli launcher you actually want to run

wstorm . &

to run the IntelliJ on the background otherwise IntelliJ closes if you happen to close the terminal you have launched the app from.

2 Comments

it still prints stdout in the console even if you run it with wstom . & which is stupid, why can't it simply work like sublime or vim
That is how linux works pal
5

As of 2019-03-09, WebStorm 2018.3.4 on Mac does not have Tools > "Create Command Line Launcher...". However, this works:

  1. WebStorm Preferences > Keymap > Main Menu > Tools > Create Command-line Launcher...
  2. Right-click "Create Command-line Launcher..." > Add Keyboard Shortcut
  3. Assign a keyboard shortcut
  4. Close Preferences
  5. Type the keyboard shortcut to open "Create Launcher Script"
  6. Click Ok to run the script
  7. You can now launch WebStorm from the terminal with webstorm and can choose a directory to open

Comments

5
  1. edit .zshrc

$ nano .zshrc

  1. add this line:

alias ws="open -na "WebStorm.app""

  1. restart terminal

now when you type ws, webstorm opens from terminal

Comments

4
  • In WebStorm IDE, click DOUBLE CLICK ON SHIFT and type Create Command Line Launcher then click OK from luncher script promote .

  • cd project_folder_path using terminal and type webstorm ./ .

that is not for Windows OS

Comments

3

In Ubuntu terminal type:

/var/opt/webstorm6/WebStorm-129.664/bin/webstorm.sh

Note: please see your WebStorm build version, code mine is 129.664

Comments

3

I know that this is a pretty old thread, but I recently came across this problem on Windows (I'm using the JetBrains Toolbox). With the following steps all new and existing applications that have been installed with the Toolbox will be added to your path!

Follow these steps to achieve this:

  1. Because of permissions, we need to create a new directory in your user. I named it .path, so that I can also store any other application there in the future. So this will be C:\Users\<PC_USER>\.path\.
  2. The the Toolbox click on the gear icon in the top right corner.
  3. Then click on Enable Shell Scripts and/or Generate Shell Scripts.
  4. In the input field that is located under the switch paste your path folder. (C:\Users\<PC_USER>\.path\)
  5. Open your Edit the system environment variables program that can be found in Windows search or the control panel.
  6. Click on the Environment Variables... button that is located in the right corner, a new window should pop up.
  7. In the new window select the variable that says Path in the Variable column from the top list and then click on the edit button that is situated under the top list. Another new window should pop-up.
  8. Click on new and paste your path there. (C:\Users\<PC_USER>\.path\)
  9. Click on Ok in Edit environment variable > Environment Variables > System Properties.
  10. Go to C:\Users\<PC_USER>\.path\ and all your toolbox installed applications should be there.
  11. Restart your CLI and it should work.

1 Comment

make sure that .path is folder, not the file
1

The wstorm command didn't work in my Git bash, so I added the following function to my .bash_profile instead:

wstorm() {
    /c/Program\ Files\ \(x86\)/JetBrains/WebStorm\ 2016.2.2/bin/WebStorm.exe $PWD/$1
}

Comments

1

In the terminal, while being in the given project folder:

webstorm .

Comments

1

A short solution relevant to the year 2021 for Linux users.

Just execute the comand:

sudo ln -s /<your path to Webstorm directory>/bin/webstorm.sh /usr/local/bin/webstorm

Since /usr/local/bin should be in the PATH environment variable by default, you should be able to run the webstorm command from anywhere in the shell.

More details Webstorm docs

Comments

1

If you want to open Webstorm through Window Powershell Terminal :

webstorm .

Terminal

. means open webstorm in current folder

Comments

0

I am running Windows 10 and whipped up a batch file (ws.bat) that implements this with optional command line argument for path to load).

:: place this batch file in your path and set to your WS EXE
:: ref: https://www.robvanderwoude.com/battech_defined.php
:: author: [email protected]

@echo off
set target=%1
if defined target (goto passedarg) else (goto noarg)

:passedarg
echo Starting WebStorm with '%target%'  
"C:\Program Files\JetBrains\WebStorm 2018.3.2\bin\webstorm.exe" %target%
goto:EOF

:noarg
echo Starting WebStorm with 'Current Dir'  
"C:\Program Files\JetBrains\WebStorm 2018.3.2\bin\webstorm.exe" .

Pretty simple but it works.

Comments

0

On Windows this worked for me:

"C:\Program Files\JetBrains\WebStorm 2023.3.4\bin\webstorm64.exe" "C:/someFile.txt"

You just need to know the exact path to the WebStorm executable you want to start. And the absolute path of the file you want to open. The quotes are needed so the paths can contain spaces.

Maybe there is a way to create a one-word "alias" for that .exe -path? Should be.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.