DEV Community

Weerayut Teja
Weerayut Teja

Posted on

Run Visual Studio Code through the terminal

The easiest way to run VS Code through the terminal is running this command

code .
Enter fullscreen mode Exit fullscreen mode

Or

code dir-name
Enter fullscreen mode Exit fullscreen mode

While dir-name is the directory name that you want to open.

But if you just fresh install VS Code, you can't run it. You will need to VS Code to path environment variable.

Setup through VS Code

Open VS Code then run Command + Shift + P

Then select "Shell Command: Install 'code' command in PATH"

Then it should be fine!

Install 'code' command in PATH automatically

But if you got the error message like this, try the second method

Error EACCESS

Add code to PATH manually

Run the command below and restart your terminal, then it should be able to run "code" command

cat << EOF >> ~/.zshrc
# Add Visual Studio Code (code)
export PATH="/Applications/Visual Studio Code.app/Contents/Resources/app/bin:$PATH"
EOF
Enter fullscreen mode Exit fullscreen mode

Top comments (0)