Join my Laravel for REST API's course on Udemy 👀

Start the Windows Terminal in the WSL home directory

April 2, 2021  ‐ 2 min read

I have bought myself a cheap Windows laptop lately. Mostly because it comes in handy to have an installation of Microsoft Word. But the Windows Subsystem for Linux (WSL) caught my interest too. Without too much of a hassle you can get yourself a Linux distro to run in Linux. Next, the very first thing you should do is get the Windows Terminal from the Microsoft Store. It just works some much nicer than cmd.

One thing that really annoys me when opening up my WSL in the Windows Terminal is the fact that it does not open in the home directory of the Linux installation. This flaw can luckily be fixed in the settings.json file of the Windows Terminal. You should be able to open this settings file by using the <CTRL>+, shortcut in the Windows Terminal.

By adding "commandline" : "wsl.exe ~" to the WSL profile you can get your WSL to open in the home directory. This makes the settings file looks something like:

{
    "$schema": "https://aka.ms/terminal-profiles-schema",

    "defaultProfile": "{07b52e3e-de2c-5db4-bd2d-ba144ed6c273}",

    "profiles":
    {
        "defaults":
        {
            // Put settings here that you want to apply to all profiles.
        },
        "list":
        [
            {
                "guid": "{07b52e3e-de2c-5db4-bd2d-ba144ed6c273}",
                "hidden": false,
                "name": "Ubuntu-20.04",
                "source": "Windows.Terminal.Wsl",
                "colorScheme": "Tango Light",
                "commandline" : "wsl.exe ~"
            },
            ...
        ]
    },
    ...
}