解決辦法
官方原文:
When setting the starting directory that your installed WSL distributions open to,
you should use this format: "startingDirectory": "//wsl$/",
replacing with the name of your distribution. For example, "startingDirectory": "//wsl$/Ubuntu-20.04".
打開 setting.json,找到 list 中 ubuntu 的配置:
{
"name": "Ubuntu-18.04",
"source": "Windows.Terminal.Wsl",
"startingDirectory": "//wsl$/Ubuntu-18.04"
},
這樣打開我們發現是定位到 ubuntu@DESKTOP:/$
目錄下的
如果想打開定位到 ~
目錄下,修改成如下:
"startingDirectory": "//wsl$/Ubuntu-18.04/home/phpzhi"
再次打開,發現是在 ubuntu@DESKTOP:~$
了
參照官方文檔:https://docs.microsoft.com/en-us/windows/terminal/customize-settings/profile-settings