code .
这个命令在 这份手册 中无法工作。
之前的所有步骤都成功了。如何在 OS X 终端中调用 Visual Studio Code?
pwd
/Users/mona/nodejs/myExpressApp
code .
-bash: code: command not found
我最终是通过更改工作区在 Visual Code Studio 内打开它,但为什么那个 code .
命令不起作用呢?
code .
这个命令在 这份手册 中无法工作。
之前的所有步骤都成功了。如何在 OS X 终端中调用 Visual Studio Code?
pwd
/Users/mona/nodejs/myExpressApp
code .
-bash: code: command not found
我最终是通过更改工作区在 Visual Code Studio 内打开它,但为什么那个 code .
命令不起作用呢?
通过 ⌘⇧P 快捷键打开命令面板,然后输入shell command
以查找 Shell Command:
在执行"在 PATH 中安装 'code' 命令"命令之前,使用 PATH 命令卸载 'code' 命令。
执行完命令后,重新启动终端以使新的$PATH值生效。您只需在任何文件夹中键入'code .'即可开始编辑该文件夹中的文件。"."表示当前目录。记得在之后重新启动你的机器
注意:如果你正在运行基于OSS存储库的版本,则需要运行code-oss .
(Dzeimsas Zvirblis的评论)
Shell Command: Install 'code' command in PATH
看起来只是在/usr/local/bin/
中创建了一个符号链接。 - jlucktay如果你想要永久添加它:
将这个加入到你的~/.bash_profile
中,或者如果你正在运行macOS v10.15(Catalina)或更高版本,请将其加入到~/.zshrc
中。
export PATH="$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
vim ~/.zshrc
编写 PATH 变量,并运行 source ~/.zshrc
重新加载 zsh。 - codebusta~/.zshrc
上运行良好。 - Tom Hertwhich code
返回/usr/local/bin
,但这对我起作用了。那已经在我的PATH上了,可执行文件的真实位置是您安装VS Code的位置。 - Scott McAllister操作步骤:
在我的 Mac 上,我已经使它工作:
将以下内容添加到文件.bash_profile中:
code() {
open -a Visual\ Studio\ Code.app $1
}
保存并在终端中执行source .bash_profile
。
然后在终端中,code index.html
(或其他文件名)将在Visual Studio Code中打开该文件。
只需按照以下步骤执行一个简单的命令:
打开Visual Studio Code应用程序
Command + Shift + P
键入命令“install code”,然后按Enter键。
哇,就这样,完成了。
现在,在需要使用的地方使用命令Code .
即可。
Code .
" 在这里的问题上不会起作用(Mac)。它可能在Windows系统上起作用。在Linux系统上,我得到了"Command 'Code' not found
"。 - Peter Mortensen对于 Mac OS X,你可以通过三种方式启用code .
来在Visual Studio Code 中打开当前文件夹。
通过 Homebrew 安装 Visual Studio Code
可以通过 Brew-Cask 安装 Visual Studio Code。
brew cask install visual-studio-code
上述命令应该会安装 Visual Studio Code,并设置 Visual Studio Code 命令行调用。
如果以上步骤不起作用,那么您可以手动完成。按照 Microsoft Visual Studio Code 文档这里给出的说明。
如果已经安装了 Visual Studio Code,则无需重新安装。您可以遵循以下任一选项。
选项 1:更新 Bash profile 中的 PATH
通过导出 Visual Studio Code 应用程序的 app/bin
路径来更新您喜欢的 Bash profile,例如 ~/.bash_profile
或 ~/.bashrc
或 ~/.zshrc
。您可以将下面的 export
命令添加到您喜欢的 Bash profile 中。
export PATH="$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
选项 2:使用 Visual Studio Code Command Palette
我们也可以在 Visual Studio Code Command Palette 中运行 shell 命令。要这样做,我们需要通过 (⇧⌘P) 打开Command Palette 并输入“shell command”以查找名为以下内容的 shell 命令:
Shell Command: Install 'code' command in PATH
按 Enter 执行上述 shell 命令。
就是这样。
code-insiderr .
。 - owaiscode-insiders .
- Rotkiv