如果想要在zsh中使用code命令启动vscode,可以编辑 ~/.zshrc 文件,添加如下代码
function code {
if [[ $# = 0 ]]
then
open -a "Visual Studio Code"
else
local argPath="$1"
[[ $1 = /* ]] && argPath="$1" || argPath="$PWD/${1#./}"
open -a "Visual Studio Code" "$argPath"
fi
}
然后source ~/.zhsrc 使文件生效,我们即可使用 code 命令启动vscode