乐闻世界logo
搜索文章和话题

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

1个答案

1

The most common way to open Visual Studio Code from the command line on OSX is by using the code command. If you have installed Visual Studio Code and added the code command to your PATH, you can follow these simple steps:

  1. Open the Terminal.
  2. Use the cd command to navigate to the project folder. For example, if your project is in the MyProject folder on the Desktop, you can enter:
    bash
    cd ~/Desktop/MyProject
  3. In the target folder, enter the code . command to open Visual Studio Code:
    bash
    code .
    This command opens the current directory in Visual Studio Code.

If the code command is not available, you may need to install or enable the command-line tool in Visual Studio Code. Follow these steps to set it up:

  1. Open Visual Studio Code.
  2. Use the shortcut Shift + Command + P to open the command palette.
  3. Type Shell Command: Install 'code' command in PATH and select it.

This will install the code command to your system PATH, after which you can use it in the terminal as described.

2024年8月10日 01:28 回复

你的答案