Windows terminal ubuntu how to change starting directory

Viewed 6021

I am wondering how to change the starting directory of my windows terminal from /home/user/ to C:/Users/user. I tried a few things I found, but nothings works. This is my current profile specified in the settings.json file:

{
  "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
}

but when I open the terminal the prompt is user@laptop:~$ and pwd gives /home/user/

5 Answers

If you mean wsl, you can set startingDirectory just like this:

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

You can explore the path \\wsl$ in Windows Explorer.

This works for me (on Windows Terminal 1.0.1401.0, WSL2 and Ubuntu 20.04):

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

The issue was that there was an auto-generated ubuntu profile in addition to the one I created. I started using the auto-generated one and removed the "commandline" : "ubuntu" option and it now listens to the startingDirectory

for me it worked when i added the version number: //wsl$/Ubuntu-20.04/home/username

To change the starting directory of windows terminal:

  • Open windows terminal settings

enter image description here

  • Go to Ubuntu profile page and change "Starting Directory" to \\wsl$\Ubuntu\home\<user>

enter image description here

Note: I posted another answer cause it did not work for me using forward slashes

Related