不能在mac(zsh)中为vs代码使用命令行参数

问题描述 投票:0回答:1

我正在尝试为vscode使用命令行参数,但它将这些参数视为目录

已经完成的步骤:1-运行Shell命令:在PATH中安装'code'命令从vs代码2-机器重新启动以使PATH生效

代码命令行语法:code [path] [arguments],在下面的例子中-h指的是help

请参考https://code.visualstudio.com/docs/editor/command-line

EG

code -h

得到:

The file /Users/dshamim/-h does not exist.

运行“代码”给出:

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
}
/usr/local/bin/code
/usr/local/bin/code

任何人经历过这个或如何让命令行参数工作?我需要通过代码--list-extensions导出扩展列表

visual-studio-code
1个回答
2
投票

看起来你有一个函数code定义在你的.bashrc(或.zshrc,取决于你正在使用的shell)的某处。它会覆盖脚本/usr/local/bin/code

功能本身不正确。 open -a "app name"不允许将参数传递给应用程序,open -a "Visual Studio Code" "$argPath"将参数传递给某个位置。

您需要找到该功能并将其删除。然后,您需要使用CLI关闭窗口并打开一个新窗口。

此外,如果您只想通过--list-extensions,您可以尝试这样做

ELECTRON_RUN_AS_NODE=1 /Applications/Visual\ Studio\ Code.app/Contents/MacOS/Electron /Applications/Visual\ Studio\ Code.app/Contents/Resources/app/out/cli.js --list-extensions
© www.soinside.com 2019 - 2024. All rights reserved.