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