修改 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

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