简体   繁体   English

如何从命令行运行 Visual Studio Code?

[英]How to run Visual Studio Code from the command line?

I am following the following instructions https://code.visualstudio.com/docs/setup/mac but I have no success.我正在遵循以下说明https://code.visualstudio.com/docs/setup/mac但我没有成功。 This is what happens when I enter这是我进入时发生的情况

➜  ~ shell command

I am getting the following:我得到以下信息:

zsh: command not found: shell

I looked up the following question as well How to open Visual Studio Code from the command line on OSX?我还查了以下问题如何从 OSX 上的命令行打开 Visual Studio Code? , it didn't help. ,它没有帮助。

I have only one terminal option in the VSCode, zsh.我在 VSCode 中只有一个终端选项 zsh。

In order to have code open Visual Studio Code from the terminal, you need to add it to the PATH by starting it (from the Launchpad, or Applications), then open its command palette by entering cmd + shift + P .为了有code从终端打开Visual Studio代码,则需要通过启动它(从启动,或应用程序),将其添加到PATH,然后通过输入打开其命令调色板cmd + shift + P A little text box you can type into will pop up near the top of the window.您可以输入的小文本框将在窗口顶部附近弹出。 Type in "shell command" and with the arrow keys you should navigate to the option that says Install 'code' command in PATH and press ENTER.输入“shell 命令”并使用箭头键导航到Install 'code' command in PATH的选项,然后按 Enter。

Now you can cd into a directory and do code .现在您可以cd进入一个目录并执行code . to open VS Code with that directory as the working project directory.以该目录作为工作项目目录打开 VS Code。

You might need to close and reopen your terminal in order for your shell to use the new alias.您可能需要关闭并重新打开终端,以便 shell 使用新别名。

  1. Open Visual Studio打开 Visual Studio
  2. cmd + P(MacOS) or CTRL + P(windows) cmd + P(MacOS) 或 CTRL + P(windows)
  3. will executed a search floating text将执行搜索浮动文本
  4. type '>shell'(with out the single quotes)输入 '>shell'(不带单引号)
  5. choose/select from the options "Shell Command: Install PATH..."从选项“Shell Command: Install PATH...”中选择/选择

all set !搞定 !

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM