如何让 Windows 10 终端启动 WSL? [英] How do I get Windows 10 Terminal to launch WSL?

查看:85
本文介绍了如何让 Windows 10 终端启动 WSL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用新的 Windows 终端,并试图让它启动我的 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
        }

但它所做的只是打开某种 CMD.

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

运行 WSL 终端的正确命令是什么

What's the correct command to run the WSL terminal

我确实注意到 GUID 与常规 CMD 相同,因此我对其进行了更改.然后它确实启动了一个外部 shell.

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.

推荐答案

您需要先做以下事情.

You need to do following things first.

1.安装 Linux(例如 Ubuntu)

在微软商店搜索Ubuntu",然后购买并安装.这实际上是 WSL (Windows Subsystem for Linux).

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

当然,你想体验其他版本的Linux,还有Debian:

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


<强>2.启用 WSL 权限

安装 WSL 版 Linux 后,还需要启用 WSL 权限:

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

使用以管理员身份运行"打开另一个 PowerShell 窗口.

Open another PowerShell window with "Run as Administrator".

然后输入以下命令:

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

命令完成后,可以在内置终端中执行Linux命令.

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

首先在cmd中输入ubuntu,花点时间启动Ubuntu,设置用户名和密码.

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

然后就可以愉快的玩Ubuntu了.下面我输入了一些常用的命令如pstouchls等,如下图.

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


<强>3.更改设置

点击上图右上角的设置",打开profile.json文件.然后在 profile.json 文件中的 "profiles" 单词内,添加以下代码段.

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"
        }

profile.json 文件中的 "schemes" 词附近,需要更新如下:

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"
            ]
        }

完整的设置文件(profile.json)可以获取这里.

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

实际上,这里的 WSL 是 Ubuntu.

Actually, the WSL here is Ubuntu.


4.为不同类型的标签添加图标

您可以在此位置添加 Tab 图标:

You can add icons for Tab to this location:

 %LOCALAPPDATA%\packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\RoamingState 

我在这个文件夹中放了一些 32x32 PNG,然后在 profile.json 中我可以引用以 ms-appdata:// 开头的路径的图像资源.

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:// .

该图标在此处可用:图标

然后用之前的设置替换下面新的 profile-withIcons.json 文件的内容.profile-withIcons.json

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:

最终结果是:

这篇关于如何让 Windows 10 终端启动 WSL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆