命令代码。这本手册里没有。
之前的所有步骤都奏效了。如何在OS X终端中调用Visual Studio代码?
pwd
/Users/mona/nodejs/myExpressApp
code .
-bash: code:命令不存在
我最终通过改变工作空间从Visual Code Studio中打开它,但是为什么命令代码不会。部分工作?
命令代码。这本手册里没有。
之前的所有步骤都奏效了。如何在OS X终端中调用Visual Studio代码?
pwd
/Users/mona/nodejs/myExpressApp
code .
-bash: code:命令不存在
我最终通过改变工作空间从Visual Code Studio中打开它,但是为什么命令代码不会。部分工作?
当前回答
下面是我在Mac上使用它的步骤:
从Visual Studio Code安装“Shell”扩展:
重新启动Visual Studio代码。
打开Visual Studio Code时按F1。
输入“Shell”并选择以下选项: Shell命令:在PATH命令中安装“code”命令:
这将给你以下消息: Shell命令“code”已成功安装在PATH中。
运行"which code"命令将给你一个'code'命令正在工作的证明:
其他回答
我尝试了以下文档,它对我有用:
启动Visual Studio代码 打开命令面板(Cmd + Shift + P),输入'shell Command '来查找 Shell命令:在PATH命令中安装“code”命令 重启终端
下面是我在Mac上使用它的步骤:
从Visual Studio Code安装“Shell”扩展:
重新启动Visual Studio代码。
打开Visual Studio Code时按F1。
输入“Shell”并选择以下选项: Shell命令:在PATH命令中安装“code”命令:
这将给你以下消息: Shell命令“code”已成功安装在PATH中。
运行"which code"命令将给你一个'code'命令正在工作的证明:
在Ubuntu 20.04 (Focal Fossa)中:
# Symbolic link the bin command to /usr/bin
rm -f /usr/bin/code
ln -s /usr/share/code/bin/code /usr/bin/code
Mac OS X
下载Visual Studio Code for Mac OS X。 双击onvcode -osx.zip展开内容。 拖动Visual Studio Code。将app移到Applications文件夹中,使其在Launchpad中可用。 通过右键单击图标并选择“选项”,“保持在Dock中”,将Visual Studio代码添加到Dock中。
提示:如果您想从终端运行Visual Studio Code,请将以下内容附加到~/。Bash_profile文件(~/.)zshrc如果你使用Z shell(可执行zsh))。
code () { VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $* ;}
现在,您可以简单地键入代码。在任何文件夹中开始编辑该文件夹中的文件。
如果你在使用命令面板解决方案时遇到问题,你可以在终端启动时手动将Visual Studio Code添加到$PATH环境变量中:
cat << EOF >> ~/.bash_profile
# Add Visual Studio Code (code)
export PATH="$PATH:/Applications/Visual Studio
Code.app/Contents/Resources/app/bin"
EOF