WSL-2 `code` 命令安装 vscode 而不是使用本地 windows 安装

WSL-2 `code` command installs vscode instead of using local windows install

我为 windows 安装了本地 vscode。 之后我设置了 wsl-2 并将其用作我的 shell。 当我尝试使用 code filename 命令打开包含代码的文件时,它会重新安装 vscode 而不是使用本地 windows 安装。

Installing VS Code Server for x64 (054a9295330880ed74ceaedda236253b4f39a335)

有没有办法让 wsl 在通过代码命令触发时使用 windows 安装?

我不特别介意使用 or,但是 settings/extensions 等一个不被另一个使用。

通过检查 Git Bash 触发它时代码的位置 (type -a code) 并将其与 ubuntu wsl shell,我得出的结论是,实际上触发的是同一个安装,。不过,我将不得不检查为什么某些扩展似乎没有“延续”。

被触发的代码是一个脚本,在 WSL.

中被触发时表现不同

别名怎么样?

# Set alias
alias code2='/mnt/c/Users/Username/AppData/Local/Programs/Microsoft\ VS\ Code/bin/code'

# Open a file now
code2 file.txt