Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get Windows 10 Terminal to launch WSL?

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.

like image 586
Wayne Werner Avatar asked Jun 26 '19 04:06

Wayne Werner


People also ask

How do I start WSL from terminal?

To start using WSL, open up a PowerShell terminal and type wsl . If you've set up WSL correctly, you'll enter a bash terminal running on the WSL distro of choice. From here, you can run any Linux commands you wish. Below you will find a reference to all of the options the wsl.exe provides when starting up.

How do I start WSL in Windows 10?

If you're running a 32-bit process in order to access wsl.exe (a 64-bit tool), you may need to run the command in the following manner: C:\Windows\Sysnative\wsl.exe --command .

How do I access WSL2 terminal?

Open up PowerShell again and run the following command wsl.exe --shutdown . This will restart the wsl virtual env. Open up Windows Terminal and WSL2 will start up automatically.

How do I turn on WSL?

To run a specific wsl distribution from within PowerShell or Windows Command Prompt without changing your default distribution, use the command: wsl -d <DistributionName> , replacing <DistributionName> with the name of the distribution you want to use.


2 Answers

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

like image 96
Bravo Yeung Avatar answered Sep 23 '22 02:09

Bravo Yeung


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 
like image 45
elhef Avatar answered Sep 23 '22 02:09

elhef