Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open Visual Studio Code from the command line on OSX?

The docs mention an executable called code, but I'm not sure where I can find that so I can put it on my path. The zip I downloaded from the VSCode site did not include any such executable. (I am able to run the .app just fine.)

Is this a Windows-only thing?

like image 896
Nick Heiner Avatar asked Apr 30 '15 14:04

Nick Heiner


People also ask

How do I start Visual Studio from command line?

On the Start screen, press Ctrl+Tab to open the Apps list, and then press V. This brings up a list that includes all installed Visual Studio command prompts.


2 Answers

From the Visual Studio Code Setup page:

Tip: If you want to run VS Code from the terminal by simply typing 'code', VS Code has a command, Shell Command: Install 'code' command in PATH, to add 'code' to your $PATH variable list.

After installation, launch VS Code. Now open the Command Palette (F1 or ++P on Mac) and type shell command to find the Shell Command: Install 'code' command in PATH command.

After executing the command, restart the terminal for the new $PATH value to take effect. You'll be able to simply type 'code .' in any folder to start editing files in that folder.

like image 55
Shaan Avatar answered Oct 24 '22 14:10

Shaan


⚡️ The Easy Solution.

  1. Download, install and open Visual Studio Code.
  2. Open the Command Palette ( + + P on Mac) OR ViewCommand Palette

🌟 3. Type shell command to find Shell Command: Install 'code' command in PATH command

  1. Install it and you're done

📟 Here's a complimentary GIF.

Install Code on Command line

After that, you can use code or code . in the terminal.

code 

Peace! ✌️

If you'd like to go a little bit further and learn a couple of great tips/tricks for using the VSCode CLI, I made a YouTube video on my workflows.

like image 21
Ahmad Awais Avatar answered Oct 24 '22 13:10

Ahmad Awais