使用“.code”快捷方式使用 VS Code 时出现“-bash: //MacOS/Electron: No such file or directory”

tha*_*der 11 linux ide terminal visual-studio-code

我的 IDE 是 VS Code 当我在终端中打开 VS Code 时,我突然使用了它很多次

. code或者source code

它显示错误

-bash: //MacOS/Electron: No such file or directory
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.
Run Code Online (Sandbox Code Playgroud)

[流程完成]

我该如何解决?我只是想让我的正常代码与以前一样再次正常工作

Tin*_*iny 23

我访问了https://vscode-docs.readthedocs.io/en/stable/editor/setup/

然后,我将以下内容复制并粘贴到系统 ~/.zshrc 文件中的新行中

code () { VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $* ;}

不要忘记source ~/.zshrc之后重新启动终端

效果很好,现在我可以code .再次运行任何文件夹/项目


小智 0

尝试这个

cat << EOF >> ~/.bash_profile
# Add Visual Studio Code (code)
export PATH="\$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
EOF
Run Code Online (Sandbox Code Playgroud)

https://code.visualstudio.com/docs/setup/mac