How to Open Visual Studio Code from the Terminal on Mac

As a long-time Mac and Visual Studio Code user, I often find myself needing to open VS Code from the command line. Whether I'm already working in the terminal or want to quickly reference something in a code project without switching contexts, launching VS Code from the terminal can be extremely convenient.
Over time, I've refined my approach to streamline this process. In this post, I'll share exactly how I open Visual Studio Code through a macOS terminal with just a few keystrokes. While extremely simple, these steps save me significant time that compounds daily.
Why Open Visual Studio Code through Terminal?
Here's why I prefer firing up VS Code directly from the terminal:
No Context Switching - If I'm already working on the command line, I don't have to switch mental contexts to open the graphical UI. Launching from the terminal keeps me focused.
Navigate Directly to Projects - I can launch VS Code directed right at whatever project folder I want. It opens exactly where I need it.
Keyboard-Driven Efficiency - I never have to leave the keyboard. As small an optimization, as this is, those seconds saved really add up.
For such a common task, eliminating all GUI navigation and mouse clicks makes a surprising difference in development speed and focus.
Prerequisites Before Opening from Terminal
To open Visual Studio Code from the macOS terminal, you just need:
Visual Studio Code - Obviously you need VS Code installed first. I recommend installing the latest stable version from https://code.visualstudio.com.
Command Line Tools - You need Xcode command line tools installed to have the
opencommand available. Just runxcode-select --installto add these if you haven't already.
That's it! With these two things set up, you're ready to launch VS Code super fast from the terminal.
How to Launch Visual Studio Code from Terminal
Here is the exact command I run to open VS Code from the terminal directed right at a project folder:
open -n -b com.microsoft.VSCode --args $PWD
Let's break this down piece by piece:
openlaunches applications from the terminal-nopens a new instance even if already running-bopens the specified bundle IDcom.microsoft.VSCodeis VS Code's bundle id--argspasses directory argument$PWDpasses the current working directory
This means: "Open a new VS Code instance pointed at the current folder location."
When I run this from a project folder, it will immediately open that codebase in a fresh VS Code window!
Customizations and Variations
Here are some tweaks and variations on this approach:
Omit
-nto reuse an existing instance when availableChange
$PWDto any absolute directory path to open other locationsAdd file names to open those directly
--args $PWD src/file.jsCreate handy terminal aliases and shell functions to save more keystrokes
For example:
alias vsc="open -n -b com.microsoft.VSCode --args \$PWD"
Now you can simply run vsc to launch VS Code!
Closing Thoughts
That's really all there is to opening Visual Studio Code directly from the macOS terminal with maximum efficiency.
While a simple tweak, directing VS Code to instantly open at specific projects saves me significant time. Over a year or more, those seconds really compound into hours saved and greater focus maintained.
I hope this little terminal trick helps you streamline your workflow as well! Let me know if you have any other questions.






