命令代码。这本手册里没有。

之前的所有步骤都奏效了。如何在OS X终端中调用Visual Studio代码?

pwd

/Users/mona/nodejs/myExpressApp

code .

-bash: code:命令不存在


我最终通过改变工作空间从Visual Code Studio中打开它,但是为什么命令代码不会。部分工作?


当前回答

对于那些使用iTerm2运行Z shell的人,请将此添加到~/中。zshrc中。

alias code="/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/code"

其他回答

我愚蠢地删除了/usr/local/bin/code符号链接,不知道正确的路径。Homebrew重装重新创建:

brew cask reinstall visual-studio-code

这条路原来是:

/usr/local/bin/code ->
'/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code'

设置代码。只要一秒钟

只需按照以下步骤执行一个简单的命令:

打开Visual Studio Code应用程序 Command + Shift + P 输入命令'install code'。然后进入。

嘣,搞定了。

现在使用命令Code。在你想使用它的地方。

命令行解决方案的替代方案:

最近我在Mac OS x中使用服务。我向文件夹或文件添加了服务,这样我就可以在Visual Studio Code中打开该文件夹或文件。我认为如果你正在使用Finder应用程序,这可以替代使用'code .'命令。

以下是步骤:

Open Automator App from Application (or you can use Spotlight). Click on the New Document button to create a new script. Choose 'Service' as a new type of document. Select 'files and folders' in 'Service receives selected' dropdown. Search for 'Open Finder Items' action item. Drag that action item to the workflow area. Select the 'Visual Studio Code.app' application in the action 'Open with' dropdown. Press Command + S to save the service. It will ask a name of service. Give it a name. I gave 'Open with Visual Studio Code'. Close the Automator app. Check the image below for more information.

验证:

打开Finder应用程序。 右键单击任何文件夹。 在上下文菜单中,寻找“使用Visual Studio Code打开”菜单选项。 点击“用Visual Studio Code打开”菜单选项。 该文件夹应该在Visual Studio Code应用程序中打开。查看下面的图片了解更多信息。

如果这种情况发生在Linux Mint或Ubuntu上,很可能是因为您通过软件管理器安装了Visual Studio Code。这将在调试过程中引起其他问题。相反,使用Visual Studio Code网站上的.deb文件安装它。

如果你真的想使用软件管理器,下面的解决方案仍然有效:

使用find / name code 2> /dev/null查找Visual Studio code二进制文件的路径。它应该以/extra/vscode/bin/code结尾

如果你正在使用Linux Mint软件管理器,你可能只会在中间找到一个长得离谱的名字,就像这样:

“... / stable / 7a22830d9e8fbbdc9627e43e072005eef66c14d2a4dd19992427ef4de060186a / ...”

只需将长部分替换为"/active/"

一旦你有了它,创建一个符号链接:

Ln -s path_you_found/extra/vscode/bin/code /usr/local/bin/code

如果你没有权限,或者只希望自己可以访问它,只需将这一行添加到你的.bashrc或.zshrc文件中:

导出路径= " $路径:path_you_found /额外的/ vscode / bin /

注意,我移除了末尾的“code”文件名。

Use:

sudo rm /usr/local/bin/code

打开Visual Studio Code,然后按Ctrl + Shift + P

然后写命令安装代码,你会得到一个弹出窗口。然后按照指示做!