How to Open VS Code from Terminal Mac

As a developer, opening VS Code from the command line in the Terminal application is a great feature. To open VS from Mac Terminal, you must type the command as shown below:


Simple, right? It is, but to get this simple command to work, you will need to do a quick setup.

My name is Eric, and as a software engineer, I am always looking for ways to streamline and make things easier, which makes coding and creating software more efficient. Shortcuts like the one above are one way to do this, and I can show you how.

If you want to see how to set up your VS Code to easily open it from the Terminal application on your Mac, keep reading. I will show you how to set this up and download VS Code for free if you don’t already have it.

Do you have VS Code Installed on your Mac?

Of course, opening VS Code from Terminal requires first having VS Code installed on your Mac. If you have come to this page looking for answers on how to open it from Terminal, chances are you have it installed, but if you don’t, it’s not a problem. I will show you below.

Step 1: Download the free VS Code zip file from Microsoft

Navigate to the link above, and your download of VS Code should start automatically. If it does not, look for the link at the top of the page to start the download. The zip file should end up in your downloads directory, ready to be extracted.

Step 2: Extract the application from the zip file

Use Finder to go to your downloads directory and double-click on the file called This will extract the application file you need to run VS Code. The extracted file will be called Visual Studio

Step 3: Drag the Visual Studio file to Applications

Locate the Visual Studio file in the downloads directory using Finder. Click on the file and drag it to your Applications folder. This will make it available from Launch Pad, and it will be easier to find.

Step 3: Double Click on the Application to start it up

Using Finder or Launch Pad, double-click on the Visual Studio file, and the application will start up.

Configure VS Code to Open from the Terminal Command Line

Once the VS Code application is downloaded and installed, you will need to configure it so that the command to open it is in your path. This is so that when you type the code command in Terminal, it will know the location of the application and be able to open it.

Configuring VS Code to open from the Terminal command line can be done in just a few steps, as shown below.

Step 1: Open VS Code

Open the VS Code application on your desktop by double-clicking on it in Finder or LaunchPad. You should see the application as shown above.

Step 2: Find the Shell configuration command

In the VS Code application, press the SHIFT+COMMAND+P keys. This will display some commands in the search window, as shown below.

Step 3: Type Shell in the search field

In the search field at the top of the VS Code application window, you will see a > character. Type Shell next to the > character in the search field.

Step 4: Run the Shell configuration command

If the command Shell Command: Install ‘code’ command in PATH is selected, you can just hit enter. Otherwise, click on Shell Command: Install ‘code’ command in PATH. You will then see a popup window showing that it will run a script to update the path.

Click OK to continue.

Step 5: Enter your password

It will prompt you to enter your password. This will be the password you use to log in to your Mac. You will need to have administrator privileges on your Mac to do this. It will allow you to enter your password or use your touch id if you have it set up.

Once you enter your password or touch id, it will update the path, and you will be ready to open VS Code from the command line in the Terminal application.

Open VS Code from Terminal Command Line

Once the setup steps above have been completed, opening VS Code from the command line is as simple as opening the Terminal application and typing the code command, as shown at the beginning of this article.


There are a couple of other ways that you can run the command. For example, you might want to specify a directory to look at when VS Code opens. This way, you can look at and find specific files you want to work with in VS Code.

Typing the command:

code .

This will open VS Code in your current directory. It will ask if you trust the files and folders, and you can click the yes button.

When VS Code opens, you will see the list of files and folders in the pane on the left side of the VS Code application.

You can also specify a specific directory in the command, as shown below.

code test_c

I can have VS Code open a specific file by using a command like the one below.

cd test_c

code test.cpp

As you can see in the image above, VS Code started up and opened the specified file in the editor. Having this command and its options can be very useful when using VS Code as your coding editor.


Once configured, it is relatively easy to open VS Code from Terminal, but you may still have some questions surrounding the process. Below are a few common ones that I often see on this topic.

What is VS code?

VS Code or Visual Studio Code is a source code editor offered by Microsoft. It is available for Windows, Linux, and macOS platforms and lets you do more than just type and edit source code. It has many other features, including integration with compilers, debuggers, source code control, syntax highlighting, auto-completion, and more.

Why Not use nano or vi from Terminal?

If you’re developing and testing in Terminal, you might ask why not just use vi or nano since they are available editors in Terminal. Many old-school programmers (me included) learned on those old editors, and they work great, but a tool like VS code has many features and can integrate with many other tools. It is well worth looking at it to see how you like it.

What kind of files can I open with VS Code?

VS Code can open almost any file, but the code syntax highlighting, auto-complete, and other features only work with source code file types such as C#, C, Java, Python, and just about any other popular programming language files. 


You can open the VS Code editor from Mac Terminal by simply configuring it so that the code command is in your path. The steps are shown above; you can do them quickly and easily. Once completed, you can open VS Code in specific directories or open specific files if needed.

I hope the information provided above has helped you to be able to open VS Code from Terminal Mac. Please let me know if you have any questions or comments. I would love to hear from you.

Leave a Reply

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