The easiest way to run VS Code through the terminal is running this command
code .
Or
code dir-name
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!
But if you got the error message like this, try the second method
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
Top comments (0)