DEV Community

Weerayut Teja
Weerayut Teja

Posted on

3 3

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

Reinvent your career. Join DEV.

It takes one minute and is worth it for your career.

Get started

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay