Open Visual Studio Code from the Terminal on macOS

It is useful to be able to open VSCode from the command line with the code command.

To add this ability, edit your PATH as follows:

PATH=$PATH:/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin

Add this to your .bash_profile or equivalent.

This will ensure your shell will find the code binary from VSCode while in any directory.

Now you can open any file in your current working directory with VSCode using:

$ code file.js

Or just open the editor without a file in the current directory:

$ code .

 

Leave a Reply

Your email address will not be published. Required fields are marked *