To access and open VS Code directly from your terminal, do the following:

  • Open your Bash or zsh profile.
open ~/.zshrc
  • Add path to the VS Code application to your PATHS variable.
# Add Visual Studio Code (code)
export PATH="$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
  • Reload your updated terminal profile.
source ~/.zshrc
  • You can now open VS code by running code xxx from anywhere in your computer.

References: