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
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.
vim ~/.zprofile
code () { VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $* ;}
source ~/.zprofile
.code .
opens your current folder in VS Code!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.
For windows Users just type in
>code .
More commands here https://code.visualstudio.com/docs/editor/command-line
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 theShell 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.
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