Skip to main content

Command Palette

Search for a command to run...

How to Open Visual Studio Code from the Terminal on Mac

Published
3 min read
How to Open Visual Studio Code from the Terminal on Mac
P

As an experienced Linux user and no-code app developer, I enjoy using the latest tools to create efficient and innovative small apps. Although coding is my hobby, I still love using AI tools and no-code platforms.

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 open command available. Just run xcode-select --install to 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:

  • open launches applications from the terminal

  • -n opens a new instance even if already running

  • -b opens the specified bundle ID

  • com.microsoft.VSCode is VS Code's bundle id

  • --args passes directory argument

  • $PWD passes 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 -n to reuse an existing instance when available

  • Change $PWD to any absolute directory path to open other locations

  • Add file names to open those directly --args $PWD src/file.js

  • Create 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.

More from this blog

T

TheTechDeck | Tech Made Simple for Everyone

772 posts

Explore the best tech tips and tricks for Windows, Mac, Linux, Android, and gaming. Simplify tech with TechUvy's expert guides