Terminal: Set default WSL path to distro $HOME

Created on 22 Oct 2019  路  11Comments  路  Source: microsoft/terminal

Set default WSL path to distro $HOME

The default path for WSL distros is currently the Windows user path (%USERPROFILE%) but it's may be better to set it to the distro $HOME.

Proposed technical implementation details (optional)

I don't know if it's possible, but ideally in the WslDistroGenerator.cpp the command line should be conditionally set to "wsl.exe -d " + distName if startingDirectory is set in profile.json, "wsl.exe ~ -d " + distName otherwise.
Another possibility is to add a boolean setting UseWSLHome on the wsl profile.json
Thank you.

Area-Settings Issue-Feature Product-Terminal Resolution-Duplicate

Most helpful comment

As said in this issue, you can set the startingDirectory to //wsl$/distro/home/username

All 11 comments

Two ways:

  1. Add this command in .bashrc file cd ~
    Or
  2. Run this command line wsl -d Ubuntu sh -c "cd ~;exec $SHELL"

I already set "commandline" : "wsl.exe ~ -d Ubuntu" in my profile.json and it works, but it's a workaround and a standard method should be better.

As said in this issue, you can set the startingDirectory to //wsl$/distro/home/username

Ok it's another good workaround
Thank you @leoniDEV

Anyway I agree with you that the default startingDirectory for WSL should be the $HOMEof the WSL user and not the %USERPROFILE% of the Windows user

Anyway I agree with you that the default startingDirectory for WSL should be the $HOMEof the WSL user and not the %USERPROFILE% of the Windows user

Agreed, at least going by the principle of DWIM. if we're launching WSL, it should default to normal nices behaviour of logging into users home directory *within wsl, not some other directory

Is this the default directory for WSL distros when opening with ConHost?

Is this the default directory for WSL distros when opening with ConHost?

Don't understand. If I login into wsl using putty, mintty or any other terminal software, the shell prompt comes at /home/<userid> that you created at first install of wsl.

In MS terminal, the default seems to be /mnt/c/users/profile or something. This is generally not the default way

Is this the default directory for WSL distros when opening with ConHost?

Don't understand. If I login into wsl using putty, mintty or any other terminal software, the shell prompt comes at /home/<userid> that you created at first install of wsl.

In MS terminal, the default seems to be /mnt/c/users/profile or something. This is generally not the default way

When we launch wsl.exe without ~ argument it's run WSL at the working directory and when we add ~ in the argument list of WSL it's launched at the distro $HOME (/home/<userid>) directory.
If we launch <distro>.exe of a distro downloaded from the store or when we open the distro app from the start menu the directory is also set to $HOME.
I hope I answered to your question @carlos-zamora

It looks like you've got a workaround here. For the rest, we'll track them in /dup #878 and #592

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

Was this page helpful?
0 / 5 - 0 ratings