How to run Visual Studio Code from the command line? - terminal

I am following the following instructions https://code.visualstudio.com/docs/setup/mac but I have no success. This is what happens when I enter
➜ ~ shell command
I am getting the following:
zsh: command not found: shell
I looked up the following question as well How to open Visual Studio Code from the command line on OSX?, it didn't help.
I have only one terminal option in the VSCode, zsh.

In order to have code open Visual Studio Code from the terminal, you need to add it to the PATH by starting it (from the Launchpad, or Applications), then open its command palette by entering cmd + shift + P. A little text box you can type into will pop up near the top of the window. Type in "shell command" and with the arrow keys you should navigate to the option that says Install 'code' command in PATH and press ENTER.
Now you can cd into a directory and do code . to open VS Code with that directory as the working project directory.
You might need to close and reopen your terminal in order for your shell to use the new alias.

Open Visual Studio
cmd + P(MacOS) or CTRL + P(windows)
will executed a search floating text
type '>shell'(with out the single quotes)
choose/select from the options "Shell Command: Install PATH..."
all set !

Related

Add and Open Project Folder in Visual Studio Code using ZSH Terminal?

I am following a series of tutorials to learn command line and, my teacher open and adds the project folder in Atom using the command
atom .
but she is using bash shell, and I am using zsh (is the default shell macOS has since Catalina) and visual studio code.
I've tried the following commands unsuccessfully:
Visual\ Studio\ Code -a
open -a 'Visual Studio Code'
code .
open Visual\ Studio\ Code .
I just want to know what is the equivalent command to her atom . but for vs code in zsh.
The problem was that actually I needed to install the code command to PATH as specified in the official VS Code documentation:
https://code.visualstudio.com/docs/setup/mac
Launch VS Code.
Open the Command Palette (Cmd+Shift+P) and type shell command to find the Shell Command: Install 'code' command in PATH command.
Restart the terminal for the new $PATH value to take effect.
So now you'll be able to type code . in any folder to start editing files in that folder, just like in my atom . example

VS Code equivalent code . command for WebStorm which opens the current directory on the editor

Is there an equivalent or similar command for WebStorm like code . which automatically opens the directory with the VS Code editor?
Thanks to the #LazyOne comment telling me to check the command-line interface I found the answer here.
The most similar command would be:
In Windows write > webstorm.bat to open the editor from the cmd or in case you want to open a project adding the path after it > webstorm.bat C:\MyProject
In macOS, after creating a launcher script it would be $ webstorm to open the editor or in case you want to open a project $ webstorm ~/MyProject

Run / Open VSCode from Mac Terminal

I'd like to run / open Visual Studio Code from the Mac OSX Terminal by running this command code .. I found instructions here:
https://code.visualstudio.com/Docs/setup
Apparently I need to include this in my .bashrc file, so I did, but to no avail.
code () {
if [[ $# = 0 ]]
then
open -a "Visual Studio Code"
else
[[ $1 = /* ]] && F="$1" || F="$PWD/${1#./}"
open -a "Visual Studio Code" --args "$F"
fi
}
I edited the .bashrc file here:
~/.bashrc which points to /Users/username/.bashrc
Which .bashrc should I be editing?
According to the docs on Launching from the command line:
Open Visual Studio Code
Open the command pallette with Command + Shift + P (or F1)
Type Shell in command palette
Select Shell Command: Install code in PATH from suggested list
That's it.
Now open your terminal type.
$ code .
To make this change persist after restart on MacOS
Many Mac users find this is forgotten and needs to be re-applied after any restart. This may happen if MacOS has applied the quarantine attribute to VS Code, which the OS uses for the "Are you sure?" notice applied on first using apps downloaded from the internet.
To check if this attribute is applied, look for com.apple.quarantine in the list returned by this command (changing the path if that's not where you installed it):
xattr "/Applications/Visual Studio Code.app"
If that does return com.apple.quarantine, you can remove the attribute using the same command with the -d flag (alongside -r to recursively remove it from all contained files and sudo to allow the change):
sudo xattr -r -d com.apple.quarantine "/Applications/Visual Studio Code.app"
...then do Shell Command : Install code in PATH as above after the attribute has been removed, and it should persist after restart.
Credit: derflounder.wordpress.com article linked to by RicardoVallejo in this comment.
I just want to pull out Benjamin Pasero's answer from inside his comment as it seems the best solution. It is the tip given on the Setting up Visual Studio Code page where it says ...
If you want to run VS Code from the terminal, append the following to your ~/.bash_profile file (~/.zshrc in case you use zsh).
code () { VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $* ;}
Now, you can simply type code . in any folder to start editing files in that folder. [Or code test.txt to go to work on the test.txt file]
To setup path permanently for mac users;
open ~/.zshrc using the below command
vi ~/.zshrc
Add the following path
export PATH="$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
And source it using below command
source ~/.zshrc
Now close the terminal and reopen and run code . command should work properly.
follow some simple steps :
open your visual studio code (vs code).
press F1.
pallete will open in top center with symbol >
type shell .
select intall 'code' command in PATH.
it will be automatically intalled.
Now you can use from terminal by typing
$ code .
Open VSCode, press Command + Shift + P, type Shell in command palette, Select that option => Install code in PATH from suggested list in command palette.
If you are on Mac OSX Maverick,
it's ~/.bash_profile not ~/.bashrc
Try putting the code in there, close the terminal and then try again. Should be working
For Mac you can do :
View > Command Palette > Shell command > "install code command in path". I'd assume there would be something similar for other OS's. After I do
which code
and it tells me it put it in /usr/local/bin
Sometimes, just adding the shell command doesn't work. We need to check whether visual studio code is available in "Applications" folder or not. That was the case for me.
The moment you download VS code, it stays in "Downloads" folder and terminal doesn't pick up from there. So, I manually moved my VS code to "Applications" folder to access from Terminal.
Step 1: Download VS code, which will give a zipped folder.
Step 2: Run it, which will give a exe kinda file in downloads folder.
Step 3: Move it to "Applications" folder manually.
Step 4: Open VS code, "Command+Shift+P" and run the shell command.
Step 5: Restart the terminal.
Step 6: Typing "Code ." on terminal should work now.
For macOS 12.0 and above:
Open profile in Notepad
open ~/.zshrc
Create an alias for code, Paste below:
alias code='open -a "Visual Studio Code"' # open file or folder in VSCode e.g. code ~/.zshrc
Now you can open the current folder e.g. code . or any other file/folder by providing its path.
Profit
PS: You can add as many aliases as needed to open a file/folder with different editors. Just mention the editor's name in the alias. For example, open file/folder with sublime text:
alias subl='open -a "Sublime Text"' # open file or folder in sublime e.g. subl ~/.zshrc
And use it like subl .
To set up VS code path permanently on Mac OS;
just open .bash_profile using the following command on terminal
open -t .bash_profile
Then add the following path to .bash_profile
code () { VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $* ;}
save the .bash_profile file and quit the terminal. Then reopen the terminal and type code .to open VS code.
Somehow using Raja's approach worked for me only once, after a reboot, it seems gone.
To make it persistent across Mac OS reboot, I added this line into my ~/.zshrc since I'm using zsh:
export PATH=/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin:$PATH
then
source ~/.zshrc
now, I could just do
code .
even after I reboot my Mac.
For Mac users:
One thing that made the accepted answer not work for me is that I didn't drag the vs code package into the applications folder
So you need to drag it to the applications folder then you run the command inside vs code (shown below) as per the official document
Launch VS Code.
Open the Command Palette (⇧⌘P) and type 'shell command' to find the
Shell Command: Install 'code' command in PATH command.
Yo do this:
Launch Visual Studio Code.
Press Cmd ⌘ + Shift ⇧ + P to open the Command Palette.
Type in shell command and select the Shell command: Install ‘code’ command in PATH to install it.
How about a simple Bash alias that you stick in your .bash_profile ?
alias code="open -a /Applications/Visual\ Studio\ Code.app"
To open the current directory:
code .
I just made a symbolic link from the "code" program supplied in the Visual Studio Code.app bundle to /usr/local/bin (a place where I prefer to put stuff like that and which is already in my path on my machine).
You can make a symbolic link using ln -s like this:
ln -s /Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/code /usr/local/bin/code
I follow this step it work for me .😁
first open VSC .
open terminal of VSC.
Press cmd+shift+p
uninstall path .
Give permission to it.
Press cmd+shift+p
install path .
then open Mac terminal navigate to root project file
type
code . in root folder It will open VSC . :)
To set it up, launch VS Code. Then open the Command Palette (⇧⌘P) and type shell command to find the Shell Command: Install 'code' command in PATH command.enter image description here
https://code.visualstudio.com/docs/setup/mac
add below snipped in your bash profile -
PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"
code () { VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $* ;}
I moved VS Code from Downloads folder to Applications, and then i was able to run code in the terminal. I guess, it might help you too.
Open Visual Studio Code
Open the command pallette with Command + Shift + P
Type Shell in command palette
Select Shell Command: Install code in PATH from suggested list
Type code . in mac terminal
I simply created a file called code:
#!/bin/bash
open /Applications/Visual\ Studio\ Code.app $1
Make it executable:
$ chmod 755 code
Then put that in /usr/local/bin
$ sudo mv code /usr/local/bin
As long as the file sits someplace that is in your path you can open a file by just typing: code
I prefer to have symlinks in the home directory, in this case at least. Here's how I have things setup:
: cat ~/.bash_profile | grep PATH
# places ~/bin first in PATH
export PATH=~/bin:$PATH
So I symlinked to the VSCode binary like so:
ln -s /Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/code ~/bin/code
Now I can issue code . in whichever directory I desire.
Since, default shell is zsh in macOS, you can try this:
cat << EOF >> ~/.zshrc
# Add Visual Studio Code (code)
export PATH="\$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
EOF
This will add a path to your VS Code, restart your terminal and voila, you're good to go.
code example.py
alias code="/Applications/Visual\ Studio\ Code\ 2.app/Contents/Resources/app/bin/code $1"
the alias to the vs code's bin file with parameters works well
you can do code . after having sourced your bash file
open finder and go to applications and make sure that vscode exists there ,then open type in terminal export PATH="/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
Open VSCode
Go to view --> Command Palette
Search for "shell...install 'code'
Open your terminal and place in the directory you wanna open
Use $ code .
code () {
if [[ $# = 0 ]]
then
open -a "Visual Studio Code"
else
echo "Opening: "$#
"/Applications/Visual Studio Code.app/Contents/MacOS/Electron" $#
fi
}
I put that into my .bash_profile I tested it and it works.

How to open Visual Studio Code from the command line on OSX?

The docs mention an executable called code, but I'm not sure where I can find that so I can put it on my path. The zip I downloaded from the VSCode site did not include any such executable. (I am able to run the .app just fine.)
Is this a Windows-only thing?
From the Visual Studio Code Setup page:
Tip: If you want to run VS Code from the terminal by simply typing 'code', VS Code has a command, Shell Command: Install 'code' command in PATH, to add 'code' to your $PATH variable list.
After installation, launch VS Code. Now open the Command Palette (F1 or ⇧+⌘+P on Mac) and type shell command to find the Shell Command: Install 'code' command in PATH command.
After executing the command, restart the terminal for the new $PATH value to take effect. You'll be able to simply type 'code .' in any folder to start editing files in that folder.
⚡️ The Easy Solution.
Download, install and open Visual Studio Code.
Open the Command Palette (⌘ + ⇧ + P on Mac) OR View ❯ Command Palette
🌟 3. Type shell command to find
Shell Command: Install 'code' command in PATH command
Install it and you're done
📟 Here's a complimentary GIF.
After that, you can use code or code . in the terminal.
code
Peace! ✌️
If you'd like to go a little bit further and learn a couple of great tips/tricks for using the VSCode CLI, I made a YouTube video on my workflows.
If you want to open a file or folder on Visual Studio Code from your terminal, iTerm, etc below are the commands which come as default when you install Visual Studio Code
To open Visual Studio Code from command line
code --
To open the entire folder/directory
code .
To open a specific file
code file_name
eg:- code index.html
We since updated the script to the following syntax to support multiple files and folders as arguments and to fix an issue with not detecting the current working directory properly:
code () {
VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $*
}
Update for our VS Code 1.0 release:
Please use the command Install 'Code' command in path or Install 'code-insiders' command in path from the command palette (View | Command Palette) to make Code available to the command line.
For me on Macbook Book Pro 2019 MacOS version 10.15.6, shortcut to open command palette in VSCode was Shift + Command + P.
On opening it one has to just write install code and press enter.
After that just open the terminal and type code your vscode will start opening.
This was the tutorial I was looking for in this thread. It shows the way to open files in Visual Studio Code by writing code .
1.- Open the file
Bash
open ~/.bash_profile
Terminal OS
open ~/.zshrc
2.- Add in your file the :
code () { VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $* ;}
3.- Reinicialize terminal and try in the folder you want to open
code .
4.- Then you can use it as shown in this comment: https://stackoverflow.com/a/41821250/10033560
I have a ~/bin/code shell script that matches the command #BengaminPasero wrote.
#!/bin/bash
VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $*
I prefix ~/bin: to my $PATH which allows me to add a bunch of one off scripts without polluting my ~/.bash_profile script.
Note: Only for Windows Users.
As many folks already suggested ways to open code from command prompt using code . command. This will only open Visual Studio Code Stable build. But If you have downloaded Visual Studio Code Insider build/version (Which has all latest build/features but unstable version) then you need to follow below instructions in windows :
Go to Control Panel\System and Security\System. Click on Advanced System Settings
Click on Environment Variables
Under System Variables tab, Click on Edit for Path Variable
Add a new path C:\Users\tsabu\AppData\Local\Programs\Microsoft VS Code Insiders\bin
(or)
C:\Program Files\Microsoft VS Code Insiders\bin based on location at which you have installed vscode insider in your machine.
Open a new command prompt and type code-insiders . to open vscode-insider
build/version
After opening VSC and pressing (Command + Up + P) I tried typing in "shell command" and nothing came up. In order to get "Shell Command: Install 'code' command in PATH command" to come up, you must do the following:
Press (Command, Up, P)
Type > (this will show and run commands)
Then type Shell Command: Install 'code' command in PATH command. It should then come up.
Once you click it, it will update and you should be good to go!
MacOS X Launch from Command Line docs
On OSX Mavericks I created a bash script named vscode (adapted from the .bashrc in VSCode Setup) in ~/bin:
#!/bin/bash
if [[ $# = 0 ]]
then
open -a "Visual Studio Code"
else
[[ $1 = /* ]] && F="$1" || F="$PWD/${1#./}"
open -a "Visual Studio Code" --args "$F"
fi
vscode <file or directory> now works as expected.
If you are using VS Code Insiders:
code-insiders .
If you are using VS Code:
code .
If you install Your vs code in Download folder you need to move the VS code to Application folder then open the vs code ,then press shift + command + p after you will see the below image. Then you need to type code . Now you are good to go.
Try this one
Open Visual Studio Code and press Command + Shift + P then type Shell in command palette now you are able to find this option like Shell Command : Install code in PATH from suggested list in command palette. Select that options.
Open VSCode via Terminal/Command Prompt
That's it.
Now open your terminal type.
$ code .
Steps to run code . command in mac to start the VSCode app -
Open VSCode
Open command pallet(Cmd+Shift+P)
Enter Shell Command: Install 'code' command in PATH and select
You will get the notification saying Shell command 'code' successfully installed in PATH.
Restart the terminal and enter code .
This will open VSCode from the current folder files in it.
You can use the vscode: protocol that Visual Studio Code defines:
open vscode://file/full/path/to/project/or/file
You can also use
/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/code
if you do not fancy modifying your path
I discovered a neat workaround for mingw32 (i.e. for those of you using the version of bash which is installed by git-scm.com on windows):
code () { VSCODE_CWD="$PWD" cmd //c code $* ;}
its very simple:
Launching from the Command Line
You can also run VS Code from the terminal by typing 'code' after adding it to the path:
Launch VS Code.
Open the Command Palette (⇧⌘P) and type 'shell command' to find the Shell Command: Install 'code' command in PATH command.
source
https://code.visualstudio.com/docs/setup/mac
I ran: open -a "Visual Studio Code" [folder-name] to open a folder with my Visual Studio Code application. Folder name is optional if you just want to open the application. Not sure if this is exactly your use-case, but hope this helps!
This is what worked for me on Mac OS Catalina -- found here (thanks, Josiah!)
If you're on Mac OS Catalina, you need to edit your .zprofile instead of .bash_profile.
Edit your ~/.zprofile file: vim ~/.zprofile
Add the following code in it, on it's own line: code () { VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $* ;}
Save the file: :wq
Re-run the updated file: source ~/.zprofile.
Test that running code . opens your current folder in VS Code!
In my case I had to use an alias:
alias code="/<PATH TO VSCODE>/Visual\ Studio\ Code.app/Contents/Resources/app/bin/code"
You can add this alias in your ~/.bash_profile.
I added this to my ~/.profile
alias vscode='/Applications/Visual\ Studio\ Code.app/Contents/MacOS/Electron'
then
. ~/.profile
afterwards I can just do
vscode
from the terminal
Added this to /usr/local/bin/code, you might have to modify the path if they are different.
#!/usr/bin/env bash
CONTENTS="/Applications/Visual Studio Code.app/Contents"
ELECTRON="$CONTENTS/MacOS/Electron"
CLI="$CONTENTS/Resources/app/out/cli.js"
ATOM_SHELL_INTERNAL_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$#"
exit $?
Make executable afterwards
sudo chmod +x /usr/local/bin/code
I had this issue because of VS Code Insiders.
The path variable was there but I needed to rename the code-insiders.cmd inside to code.cmd .
Maybe this is useful to someone.
For windows Users
just type in
>code .
More commands here
https://code.visualstudio.com/docs/editor/command-line
If you're using visual code insiders and you want to open a file or folder in Visual Studio Code insiders from your terminal or any other command line tool then you can refer to the commands below which come by default inside visual studio code insider.
To open Visual Studio Code from command line
code-insiders --
To open the entire folder/directory
code-insiders .
To open a specific file
code-insiders file_name
eg:- code index.html
VSCode now supports it out of the box with version 1.58. Just type:
$ cd path/to/your/directory
$ code .
The instruction given at VS Code Command Line for launching a path are incorrect; the leading colon shown in the example doesn't work. However, launching with a backslash terminated directory name opens the specified directory as expected.
So, for example,
code C:\Users\DAVE\Documents\Programming\Angular\StringCalculator\src\
opens the Visual Studio Code editor in directory C:\Users\DAVE\Documents\Programming\Angular\StringCalculator\src.
Important: The terminal backslash, though optional, is useful, as it makes clear that the intend is to open a directory, as opposed to a file. Bear in mind that file name extensions are, and always have been, optional.
Beware: The directory that gets appended to the PATH list is the \bin directory, and the shell command code launches a Windows NT Command script.
Hence, when incorporated into another shell script, code must be called or started if you expect the remainder of the script to run. Thankfully, I discovered this before my first test of a new shell script that I am creating to start an Angular 2 project in a local Web server, my default Web browser, and Visual Studio Code, all at once.
Following is my Angular startup script, adapted to eliminate a dependency on one of my system utilities that is published elsewhere, but not strictly required.
#echo off
goto SKIPREM
=========================================================================
Name: StartAngularApp.CMD
Synopsis: Start the Angular 2 application installed in a specified
directory.
Arguments: %1 = OPTIONAL: Name of directory in which to application
is installed
Remarks: If no argument is specified, the application must be in
the current working directory.
This is a completely generalized Windows NT command
script (shell script) that uses the NPM Angular CLI to
load an Angular 2 application into a Node development
Web server, the default Web browser, and the Visual
Studio Code text editor.
Dependencies: Unless otherwise specified in the command line, the
application is created in the current working directory.
All of the following shell scripts and programs must be
installed in a directory that is on the Windows PATH
directory list.
1) ShowTime.CMD
2) WWPause.exe
3) WWSleep.exe
4) npm (the Node Package Manager) and its startup
script, npm.cmd, must be accessible via the Windows
PATH environment string. By default, this goes into
directory C:\Program Files\nodejs.
5) The Angular 2 startup script, ng.cmd, and the Node
Modules library must be installed for global access.
By default, these go into directory %AppData%\npm.
Author: David A. Gray
Created: Monday, 23 April 2017
-----------------------------------------------------------------------
Revision History
-----------------------------------------------------------------------
Date By Synopsis
---------- --- --------------------------------------------------------
2017/04/23 DAG Script created, tested, and deployed.
=======================================================================
:SKIPREM
echo BOJ %~0, version %~t0
echo.
echo -------------------------------------------------------
echo Displaying the current node.js version:
echo -------------------------------------------------------
echo.
node -v
echo.
echo -------------------------------------------------------
echo Displaying the current Node Package Manager version:
echo -------------------------------------------------------
echo.
call npm -v
echo.
echo -------------------------------------------------------
echo Loading Angular starter application %1
echo into a local Web server, the default Web browser, and
echo the Visual Studio Code text editor.
echo -------------------------------------------------------
echo.
if "%1" neq "" (
echo.
echo -------------------------------------------------------
echo Starting the Angular application in directory %1
echo -------------------------------------------------------
echo.
cd "%~1"
call code %1\src\
) else (
echo.
echo -------------------------------------------------------
echo Starting the Angular application in directory %CD%
echo -------------------------------------------------------
echo.
call code %CD%\src\
)
call ng serve --open
echo.
echo -------------------------------------------------------
echo %~nx0 Done!
echo -------------------------------------------------------
echo.
Pause
$> open -a "Visual Studio Code" [file-name]
link your currentily folders to vscode.
Windows Registry Editor Version 5.00
; Directory\Background\shell => on empty space
[HKEY_CLASSES_ROOT\Directory\Background\shell\vscode]
"Icon"="C:\\current-folder-vscode\\Code.exe,0"
#="VsCode"
[HKEY_CLASSES_ROOT\Directory\Background\shell\vscode\command]
#="C:\\current-folder-vscode\\Code.exe ."
; Directory\shell => on a folder
[HKEY_CLASSES_ROOT\Directory\shell\vscode]
#="VsCode"
"Icon"="C:\\current-folder-vscode\\Code.exe,0"
[HKEY_CLASSES_ROOT\Directory\shell\vscode\command]
#="C:\\current-folder-vscode\\Code.exe ."
If you install VS CODE using snap. You will need to add /snap/bin in your PATH environment variable.
so - open your .bashrc or .zshrc
and add /snap/bin in your PATH environment variable
reload terminal,
and than code comand will start it

How to open webstorm from terminal

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 ?
Try in terminal 'wstorm' and 'webstorm'
If the commands don't work you can run in WebStorm: "Tools" -> "Create Command Line Launcher..."
Note: The solution works only for Linux / MacOS
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:
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.
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.
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[#]}"
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"
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
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.
As of 2019-03-09, WebStorm 2018.3.4 on Mac does not have Tools > "Create Command Line Launcher...". However, this works:
WebStorm Preferences > Keymap > Main Menu > Tools > Create Command-line Launcher...
Right-click "Create Command-line Launcher..." > Add Keyboard Shortcut
Assign a keyboard shortcut
Close Preferences
Type the keyboard shortcut to open "Create Launcher Script"
Click Ok to run the script
You can now launch WebStorm from the terminal with webstorm and can choose a directory to open
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.
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
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
In the terminal, while being in the given project folder:
webstorm .
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:
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\.
The the Toolbox click on the gear icon in the top right corner.
Then click on Enable Shell Scripts and/or Generate Shell Scripts.
In the input field that is located under the switch paste your path folder. (C:\Users\<PC_USER>\.path\)
Open your Edit the system environment variables program that can be found in Windows search or the control panel.
Click on the Environment Variables... button that is located in the right corner, a new window should pop up.
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.
Click on new and paste your path there. (C:\Users\<PC_USER>\.path\)
Click on Ok in Edit environment variable > Environment Variables > System Properties.
Go to C:\Users\<PC_USER>\.path\ and all your toolbox installed applications should be there.
Restart your CLI and it should work.
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
}
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
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: bob#bobchesley.net
#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.
webstorm . doesn't work on Windows. Try this for the current folder:
webstorm $pwd
$pwd is the current folder's path

Resources