总体而言,我对 Linux 和 WSL 还很陌生。我能够使用它code .
在 VSCode 中打开我当前的目录,但在删除一些我不记得的东西后,它就不再起作用了。我输入命令,它就挂在那里。
我删除了我的 Ubuntu-20.04 实例并重新创建了它,但它仍然不起作用。还检查了我的 $PATH,它似乎在那里。
另外,add shell command
VSCode 中没有出现,所以我无法卸载并重新安装 shell 快捷方式。
有人知道吗?
drewbie@drewbie:/$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:/mnt/c/Windows/System32/OpenSSH/:/mnt/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Program Files/dotnet/:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Program Files (x86)/QuickTime/QTSystem/:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/Go/bin:/mnt/c/Program Files/Docker/Docker/resources/bin:/mnt/c/ProgramData/DockerDesktop/version-bin:/mnt/c/Users/Andrew/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/Andrew/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Program Files/heroku/bin:/mnt/c/Users/Andrew/AppData/Local/GitHubDesktop/bin:/mnt/c/Users/Andrew/go/bin:/snap/bin
whereis 和 which
drewbie@drewbie:~$ whereis code
code: /mnt/c/Users/Andrew/AppData/Local/Programs/Microsoft VS Code/bin/code /mnt/c/Users/Andrew/AppData/Local/Programs/Microsoft VS Code/bin/code.cmd
drewbie@drewbie:~$ which code
/mnt/c/Users/Andrew/AppData/Local/Programs/Microsoft VS Code/bin/code
按照@NotTheDr01ds在下面的帖子中说的做之后
drewbie@drewbie:~$ vi "$(which code)"
drewbie@drewbie:~$ code .
+ [ = true ]
+ COMMIT=899d46d82c4c95423fb7e10e68eba52050e30ba3
+ APP_NAME=code
+ QUALITY=stable
+ NAME=Code
+ DATAFOLDER=.vscode
+ realpath /mnt/c/Users/Andrew/AppData/Local/Programs/Microsoft VS Code/bin/code
+ dirname /mnt/c/Users/Andrew/AppData/Local/Programs/Microsoft VS Code/bin/code
+ dirname /mnt/c/Users/Andrew/AppData/Local/Programs/Microsoft VS Code/bin
+ VSCODE_PATH=/mnt/c/Users/Andrew/AppData/Local/Programs/Microsoft VS Code
+ ELECTRON=/mnt/c/Users/Andrew/AppData/Local/Programs/Microsoft VS Code/Code.exe
+ IN_WSL=false
+ [ -n Ubuntu-20.04 ]
+ IN_WSL=true
+ [ true = true ]
+ export WSLENV=ELECTRON_RUN_AS_NODE/w:WT_SESSION::WT_PROFILE_ID
+ wslpath -m /mnt/c/Users/Andrew/AppData/Local/Programs/Microsoft VS Code/resources/app/out/cli.js
+ CLI=C:/Users/Andrew/AppData/Local/Programs/Microsoft VS Code/resources/app/out/cli.js
+ WSL_EXT_ID=ms-vscode-remote.remote-wsl
+ ELECTRON_RUN_AS_NODE=1 /mnt/c/Users/Andrew/AppData/Local/Programs/Microsoft VS Code/Code.exe C:/Users/Andrew/AppData/Local/Programs/Microsoft VS Code/resources/app/out/cli.js --ms-enable-electron-run-as-node --locate-extension ms-vscode-remote.remote-wsl
答案1
答案2
答案3
我刚刚将其添加到我的 .bashrc 中:
alias code='/mnt/c/Users/[YOUR USER DIR NAME]/AppData/Local/Programs/Microsoft\ VS\ Code/bin/code'
答案4
我的工作方式与 @cloudcreatordotio 略有不同,我将这行添加到我的 .bashrc 中,步骤如下所示:
打开你的 ubuntu shell
打开 .bashrc
nano .bashrc
添加以下行
alias code="'/mnt/c/Users/[YOUR USER DIR NAME]/AppData/Local/Programs/Microsoft VS Code/Code.exe'"