macOS命令行使用code打开VS Code

2025-10-11
#Unix #macOS #Software

1. 前言

在终端直接用 code . 打开当前文件夹,Visual Studio Code 自带此功能,需进行设置。

2. 设置

  1. 打开 Visual Studio Code。

  2. 按下快捷键 ⌘ + ⇧ + P 打开命令面板。

  3. 输入并选择:

Shell Command: Install 'code' command in PATH
  1. 打开终端,输入:
code .
  1. 查看路径:
where code

/usr/local/bin/code