81

I'm using the new Windows Terminal, and trying to get it to launch my WSL terminal. This is the setting that I'm trying to use:

        {
            "acrylicOpacity" : 0.75,
            "closeOnExit" : true,
            "colorScheme" : "Campbell",
            "commandline" : "%LOCALAPPDATA%/wsltty/bin/mintty.exe --WSL= --configdir='%APPDATA%/wsltty' -~ ",
            "cursorColor" : "#FFFFFF",
            "cursorShape" : "bar",
            "fontFace" : "Consolas",
            "fontSize" : 10,
            "guid" : "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
            "historySize" : 9001,
            "icon" : "ms-appx:///ProfileIcons/{0caa0dad-35be-5f56-a8ff-afceeeaa6101}.png",
            "name" : "wsl",
            "padding" : "0, 0, 0, 0",
            "snapOnInput" : true,
            "startingDirectory" : "%USERPROFILE%",
            "useAcrylic" : true
        }

But all it's doing is opening some sort of CMD.

What's the correct command to run the WSL terminal

Edit:

I did notice that the GUID was the same thing as the regular CMD, so I changed that. Then it did launch an external shell.

1

11 Answers 11

124

You need to do following things first.

1. Install Linux (e.g. Ubuntu)

Search "Ubuntu" in the Microsoft store, then buy and install. This is actually WSL (Windows Subsystem for Linux).

1557633269919

Of course, you want to experience other versions of Linux, as well as Debian:

1557633347262


2. Enable WSL permissions

After installing the WSL version of Linux, you also need to enable WSL permissions:

Open another PowerShell window with "Run as Administrator".

1557633727047

Then enter the following command:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux 

1557633836814

After the command is completed, you can execute the Linux command in the built-out Terminal.

First enter ubuntu in cmd, take a little time to start Ubuntu, set the username and password.

Then you can play with Ubuntu happily. Below I entered a few common commands such as ps, touch, ls etc., as shown below.

1557633540178


3. Change settings

Click "Settings" in right top corner of above image, the file profile.json file will be opened. Then inside the word "profiles" in profile.json file, add below snippet.

        {
            "guid": "{78e390db-1bff-4533-9d7c-20f53d8bafa1}",
            "name": "WSL",
            "colorscheme": "Campbell",
            "historySize": 9001,
            "snapOnInput": true,
            "cursorColor": "#FFFFFF",
            "cursorShape": "bar",
            "commandline": "wsl ~",
            "fontFace": "Consolas",
            "fontSize": 12,
            "acrylicOpacity": 0.75,
            "useAcrylic": true,
            "closeOnExit": false,
            "padding": "0, 0, 0, 0"
        }

Near the word "schemes" in profile.json file, you need to update below:

"schemes": [
        {
            "name": "Campbell",
            "foreground": "#A7B191", 
            "background": "#0C0C0C",
            "colors": [
                "#0C0C0C",
                "#C50F1F",
                "#13A10E",
                "#C19C00",
                "#0037DA",
                "#881798",
                "#3A96DD",
                "#CCCCCC",
                "#767676",
                "#E74856",
                "#16C60C",
                "#F9F1A5",
                "#3B78FF",
                "#B4009E",
                "#61D6D6",
                "#F2F2F2"
            ]
        }

The complete setting file (profile.json) which can be obtained here.

Actually, the WSL here is Ubuntu.


4. Add icons to different types of tabs

You can add icons for Tab to this location:

 %LOCALAPPDATA%\packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\RoamingState 

I put some 32x32 PNG in this folder, and then in profile.json I can reference the image resource with the path starting with ms-appdata:// .

The icon is available here: Icons

Then replace the contents of the new profile-withIcons.json file below with the previous settings. profile-withIcons.json

After finishing the contents of the folder is like this:

Dir

The final result is:

Icons

7
  • @Wayne Werner FYI. Commented Jun 27, 2019 at 4:39
  • Very thorough! Nice! Commented Jun 28, 2019 at 16:44
  • 2
    The correct path for an icon in RoamingState is actually: ms-appdata:///roaming/{filename} Commented Sep 8, 2019 at 12:27
  • @BravoYeung, thanks for detailed answer.... but how to find guid?
    – Psychozoic
    Commented Mar 24, 2020 at 13:48
  • @Psychozoic make sure that you assigned a GUID string to each item in the profile file and each GUID is unique. You can use Visual Studio to generate the unique GUID, no need to find in somewhere else. Commented Mar 25, 2020 at 1:50
35

To launch any distribution, you can also use this for commandline:

wsl.exe -d <name_of_the_distribution>

Like :

wsl.exe -d Ubuntu-18.04

You can list all distributions with :

wsl.exe -l

.

PS : Tux icon for Linux :

ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png
4
  • Is there a way to open a instance of wsl.exe in a new terminal window?
    – rated2016
    Commented Jul 20, 2019 at 18:41
  • 1
    Tried cmd.exe /c start wsl.exe -c ls but terminal window closes as soon as it opens
    – rated2016
    Commented Jul 20, 2019 at 19:05
  • Thanks a lot, I was very confused with why wsl.exe -d bash wasn't executing previously when I tried it after seeing the command elsewhere, it makes sense now.
    – himanshuxd
    Commented Apr 1, 2020 at 15:42
  • 1
    As of Windows 11, setting a terminal profile to launch wsl.exe -d Ubuntu seems to give you a shell at /mnt/c/WINDOWS/system32 which is not the best starting point. You can instead get a shell at the Linux home directory by setting it to launch wsl.exe -d Ubuntu --cd ~.
    – kbolino
    Commented Mar 5, 2022 at 4:25
8

Recent versions of Windows Terminal include support for Dynamic Profiles, in which new WSL distros will automatically be added to the list of available profiles.

Screenshot of Windows Terminal with WSL profile added

However, if Windows Terminal is running when you install the new distro, it will not currently get added while running. You must exit and re-start Windows Terminal, and the new profile will automatically appear.

Once it is added, you can edit/move it using the Settings dialog or by editing settings.json as usual. Each WSL distro is identified using a GUID which will have been auto-populated.

Screenshot of settings.json being edited in Notepad++

As described in the linked article, Dynamic Profiles can be turned off by disabling their source(s) such as the following in settings.json:

"disabledProfileSources": ["Windows.Terminal.Wsl", "Windows.Terminal.Azure", "Windows.Terminal.PowershellCore"]
7

Turns out that all I needed to do was change the commandline to ubuntu1804.exe. Like this:

        {
            "acrylicOpacity" : 0.75,
            "closeOnExit" : true,
            "colorScheme" : "Campbell",
            "commandline": "ubuntu1804.exe",
            "cursorColor" : "#FFFFFF",
            "cursorShape" : "bar",
            "fontFace" : "Consolas",
            "fontSize" : 10,
            "guid" : "{0caa0dad-35be-5f56-a8ff-abceeeaa6101}",
            "historySize" : 9001,
            "icon" : "ms-appx:///ProfileIcons/{0caa0dad-35be-5f56-a8ff-afceeeaa6101}.png",
            "name" : "wsl",
            "padding" : "0, 0, 0, 0",
            "snapOnInput" : true,
            "startingDirectory" : "%USERPROFILE%",
            "useAcrylic" : false
        }
1
  • 1
    If you have multiple distributions, you can list them with wsl --list, and then specify the specific distribution with wsl --distribution Ubuntu-18.04, in my case, for the commandline parameter. Commented Mar 11, 2020 at 20:19
7

While my answer is off-question (since answered by the O.P.) I found this question while searching for adding a Windows Terminal (WT) profile for my recent Ubuntu installation, since I had recently re-imaged my laptop.

Updated 19/10/03: Installation order does not matter. My profile for “ubuntu” appears after installing ubuntu, and then launching the ubuntu instance in PowerShell and establish my user account and password. THEN Windows Terminal adds the appropriate shell profile for WSL.

2
  • It does not add it to the main configuration though. Terminal app picks up this distro is installed from somewhere else
    – Piotr Kula
    Commented Aug 13, 2020 at 13:42
  • 1
    thank you so much! that is exactly what I was looking for. I was kinda disappointed that opening a new Linux tab didn't grant me access to its directories properly. EDIT: what I do is: 1. launch Windows Terminal 2. run the command for my distro of choice, eg. ubuntu2004.exe 3. profit Commented Dec 15, 2020 at 23:21
6
  1. Open settings

Open Settings

  1. Change the "Default Profile" in the drop down.

Change the Default Profile

  1. Click "Save" on the bottom right.
6

Create a new profile in the windows terminal settings and select the following command line

C:\Windows\system32\wsl.exe -d Ubuntu-20.04

where -d selects the distribution to be run.

5

I have developed a tool for tweaking the terminal configurations here:

Windows Terminal Tweaker

It lets you add different profiles, gives color pickers to choose color schemes and provides options to tweak every single thing while applying the settings live.

0
3

Windows Terminal allows you to open the settings and change things there. If you already have ubuntu installed, it should be an option to set the ubuntu profile as your default config.

Copy paste the guid for ubuntu into the defaultProfile and it will automatically launch WSL ubuntu instead of powershell by default.

1
  • This is now the best up-to-date answer. In all my reading and scrolling I did not notice the key at the top called defaultProfile. Simply scroll down, locate the block for your WSL (or whatever), copy the guid and paste it in as the key for the defaultProfile. Restart Terminal; Done ...
    – Ari
    Commented Mar 22, 2021 at 2:47
3

The premise of the question was fouled by the mistake with the GUID, as the OP says the sample code was actually correct. So, the question could be re-interpreted as--

What is the minimum required change to the default settings.json to point to an application of your choosing? (which is what got me here)

  1. guid - has to be unique. I've had success with changing just the last number for each customization.

  2. commandline - From within Bravo Yeung's answer is a link to a sample settings.json file: "commandline": "wsl ~"

This little bitty value is made possible by setting a default distro: "The default WSL distribution is the one that runs when you run wsl on a command line:"

wsl --setdefault <DistributionName>

However, seems commandline:wsl doesn't work with startingDirectory. I've successfully omitted commandline in favor of source + startingDirectory:

// Make changes here to the cmd.exe profile.
"guid": "{long-guid-here}",
"hidden": false,
"name": "Debian",
"tabTitle" : "WSL (Debian)",
"source": "Windows.Terminal.Wsl",
"startingDirectory" : "C:\\Users\\myuser"

Here is a good link which got me started the first time I installed Windows Terminal and customized the settings, Easily add Anaconda Prompt to Windows Terminal to make life better

1

Just start windows terminal, powershell, then type "debian" or whatever distro installed. This automatically both adds it to windows terminal, tux and all, and open a new tab with wsl.

1
  • For a Ubuntu version, just enter 'ubuntu' in the Powershell Commented Nov 10 at 23:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.