Start on the right path

Start on the right path

By default, and for reasons that I'm sure make sense to someone, wsl distributions launch at your windows user's home path which for me is /mnt/c/Users/adamc.

Default behaviour when I run wsl ... why?

I definitely don't want that,  the performance of windows shares in wsl right now is not great and it's never going to be as fast as working inside the distro's file system. So I always aim to work inside the distro's filesystem and I want to start in my users home directory. WSL gives the option to specify the startup path when launching so running wsl ~ will start the default installed distro in it's home directory.

Yay a place I actually want to be

If you have multiple distros installed you can specify the distro as well as the path when you start for example wsl ~ -d Debian will open my Debian distro in my Debian user's home folder.

With Windows Terminal you can configure the command that launches your distro via the commandLine parameter of a profile. I have my terminal configured to launch Ubuntu and Debian like below which means when I launch either I always start where I want to be.

{
	"guid": "{2c4de342-38b7-51cf-b940-2309a097f518}",
	"hidden": false,
	"name": "Ubuntu",
	"source": "Windows.Terminal.Wsl",
	"commandline": "wsl ~ -d Ubuntu"
}
{
	"guid": "{58ad8b0c-3ef8-5f4d-bc6f-13e4c00f2530}",
	"hidden": false,
	"name": "Debian",
	"source": "Windows.Terminal.Wsl",
	"commandline": "wsl ~ -d Debian"
}

You can also specify the starting directory when configuring a profile. This has to be a windows path but because wsl exposes every distro under the windows network path \\wsl$\  you can access any path on any distro. So another way for me to configure my profiles would be the config below.

{
	"guid": "{2c4de342-38b7-51cf-b940-2309a097f518}",
	"hidden": false,
	"name": "Ubuntu",
	"source": "Windows.Terminal.Wsl",
	"startingDirectory": "\\\\wsl$\\Ubuntu\\home\\adam"
}
{
	"guid": "{58ad8b0c-3ef8-5f4d-bc6f-13e4c00f2530}",
	"hidden": false,
	"name": "Debian",
	"source": "Windows.Terminal.Wsl",
	"startingDirectory": "\\\\wsl$\\Debian\\home\\adam"
}

Comments

Success! Your account is fully activated, you now have access to all content.
Success! Your billing info is updated.
Billing info update failed.
Close