修改 microsoft terminal 的WSL默认打开路径

解决办法

官方原文:

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章