【问题标题】:Windows terminal ubuntu how to change starting directoryWindows终端ubuntu如何更改起始目录
【发布时间】:2020-08-31 17:17:35
【问题描述】:

我想知道如何将 Windows 终端的起始目录从 /home/user/ 更改为 C:/Users/user。我尝试了一些我发现的东西,但没有任何效果。这是我在 settings.json 文件中指定的当前配置文件:

{
  "acrylicOpacity" : 1,
  "closeOnExit" : true,
  "colorScheme" : "One Half Dark",
  "commandline" : "ubuntu",
  "cursorColor" : "#FFFFFF",
  "cursorShape" : "bar",
  "fontFace" : "Consolas",
  "fontSize" : 10,
  "guid" : "{ba50f801-2d96-4517-a737-575f32f0fb61}",
  "historySize" : 9001,
  "icon" : "C:/Users/user/Pictures/ubuntu.png",
  "name" : "Ubuntu",
  "padding" : "0, 0, 0, 0",
  "snapOnInput" : true,
  "startingDirectory" : "C:\\Users\\user",
  "useAcrylic" : true
}

但是当我打开终端时,提示符是user@laptop:~$pwd 给出/home/user/

【问题讨论】:

  • 添加"source": "Windows.Terminal.Wsl",

标签: windows-terminal


【解决方案1】:

如果你的意思是wsl,你可以像这样设置startingDirectory

"startingDirectory": "//wsl$/Ubuntu/home/user"

您可以在 Windows 资源管理器中探索路径 \\wsl$

【讨论】:

  • 适用于大多数情况,但不适用于//wsl$/Ubuntu/mnt/c - 似乎mnt/c 仅在设置startingDirectory 后才能解决。 Oscar 在下面的回答在这种情况下提供了解决方法。
  • 这个//wsl$/Ubuntu/home/username是WT Preview 1.8中唯一适合我的,只需在Settings > Profiles > Ubuntu > Starting directory中输入文本并点击保存按钮。
【解决方案2】:

这对我有用(在 Windows 终端 1.0.1401.0、WSL2 和 Ubuntu 20.04 上):

"startingDirectory": "C:/Users/user"

【讨论】:

    【解决方案3】:

    问题在于,除了我创建的配置文件之外,还有一个自动生成的 ubuntu 配置文件。我开始使用自动生成的并删除了"commandline" : "ubuntu" 选项,它现在监听startingDirectory

    【讨论】:

      【解决方案4】:

      对我来说,当我添加版本号时它起作用了://wsl$/Ubuntu-20.04/home/username

      【讨论】:

        猜你喜欢
        • 2020-10-15
        • 1970-01-01
        • 1970-01-01
        • 2017-04-20
        • 2018-07-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-06-01
        相关资源
        最近更新 更多