从 Mac 终端运行/打开 VSCode [英] Run / Open VSCode from Mac Terminal
问题描述
我想通过运行此命令 code .
从 Mac OSX 终端运行/打开 Visual Studio Code.我在这里找到了说明:
就是这样.
现在打开您的终端类型.
$ 代码.
要在 MacOS 上重新启动后保持此更改
许多 Mac 用户发现这被遗忘了,需要在任何重新启动后重新应用.如果 MacOS 已将隔离属性应用于 VS Code(操作系统将其用于您确定吗?"),则可能会发生这种情况.首次使用从互联网下载的应用程序时适用的通知.
要检查是否应用了此属性,请在此命令返回的列表中查找 com.apple.quarantine
(如果不是安装路径,请更改路径):
xattr "/Applications/Visual Studio Code.app";
如果确实返回 com.apple.quarantine
,您可以使用带有 -d
标志(与 -r
code> 递归地从所有包含的文件中删除它,sudo
允许更改):
sudo xattr -r -d com.apple.quarantine "/Applications/Visual Studio Code.app";
...then do Shell Command : Install code in PATH
删除属性后,如上所示,重启后应该保持不变.
来源:derflounder.wordpress.com 文章由 RicardoVallejo 链接到 此评论.
I'd like to run / open Visual Studio Code from the Mac OSX Terminal by running this command code .
. I found instructions here:
https://code.visualstudio.com/Docs/setup
Apparently I need to include this in my .bashrc
file, so I did, but to no avail.
code () {
if [[ $# = 0 ]]
then
open -a "Visual Studio Code"
else
[[ $1 = /* ]] && F="$1" || F="$PWD/${1#./}"
open -a "Visual Studio Code" --args "$F"
fi
}
I edited the .bashrc
file here:
~/.bashrc
which points to /Users/username/.bashrc
Which .bashrc
should I be editing?
Try this one
Open Visual Studio Code and press Command + Shift + P or F1 then type Shell
in command palette now you are able to find this option like Shell Command : Install code in PATH
from suggested list in command palette. Select that options.
That's it.
Now open your terminal type.
$ code .
To make this change persist after restart on MacOS
Many Mac users find this is forgotten and needs to be re-applied after any restart. This may happen if MacOS has applied the quarantine attribute to VS Code, which the OS uses for the "Are you sure?" notice applied on first using apps downloaded from the internet.
To check if this attribute is applied, look for com.apple.quarantine
in the list returned by this command (changing the path if that's not where you installed it):
xattr "/Applications/Visual Studio Code.app"
If that does return com.apple.quarantine
, you can remove the attribute using the same command with the -d
flag (alongside -r
to recursively remove it from all contained files and sudo
to allow the change):
sudo xattr -r -d com.apple.quarantine "/Applications/Visual Studio Code.app"
...then do Shell Command : Install code in PATH
as above after the attribute has been removed, and it should persist after restart.
Credit: derflounder.wordpress.com article linked to by RicardoVallejo in this comment.
这篇关于从 Mac 终端运行/打开 VSCode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!