linux终端和windows,使用 Windows 终端和 WSL

使用 Windows 终端和 WSL

安装 Windows Terminal

在windows 的应用商店下载安装 Windows Terminal

安装 WSL Ubuntu

开始 --> 设置 --> 更新和安全 --> 开发者选项 --> 开发人员模式

7fcec139d38e

dev-setting.png

设置 --> 应用 --> 程序和功能

7fcec139d38e

wsl-setting1.png

7fcec139d38e

wsl-setting2.png

然后按提示重启电脑。

下载 Ubuntu

在windows 的应用商店下载安装 ubuntu

启动 Ubuntu

如果第2步没有重启电脑,打开 Ubuntu 可能会出错

7fcec139d38e

error.png

启动后,输入用户名和密码,就可以使用 Ubuntu 了。

此时打开 Windows Terminal,也自动有 Ubuntu 的选项了。

把 Windows Terminal 添加到右键菜单

准备内一个图标,放到一个指定的目录下, 如 "C:\win10\icon\terminal.ico"

新建一个文本文件,后缀名改为reg,注意使用ANSI编码,内容如下:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt]

@="此处打开 Windows terminal"

"Icon"="C:\\win10\\icon\\terminal.ico"

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt\command]

@="C:\\Users\\Administrator\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe"

注意路径中的用户, 需使用自己电脑用户名。

双击运行reg,提示已经添加到注册表。此时在任意的文件夹中,右键菜单中都有“此处打开 Windows terminal”选项了。

7fcec139d38e

menu.png

虽然能打开终端,但是路径并不是当前路径,需要修改配置:

打开 Windows Terminal --> 设置,给 profiles.defaults 加上这么一句:

"startingDirectory": null

添加 git bash

给 profiles 添加一项:

{

"closeOnExit": true,

"commandline": "\"%PROGRAMFILES%\\git\\usr\\bin\\bash.exe\" -i -l", // gitbash的命令行所在位置

"guid": "{1c4de342-38b7-51cf-b940-2309a097f589}", // 唯一的标识

"historySize": 9001,

"icon": "C:\\win10\\imgs\\icons\\git.png", // git的图标,打开终端时候会看到

"name": "Git cmd" // tab栏的标题显示

}

7fcec139d38e

gitbash.png

设置主题

这里 有很多的主题。

例如,设置一个 windows Terminal 自带的主题 “Solarized Dark”,并且在右下角添加一个龙猫的小图片,配置如下:

{

// Make changes here to the powershell.exe profile.

"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",

"name": "Windows PowerShell",

"commandline": "powershell.exe",

"colorScheme": "Solarized Dark",

"hidden": false,

"backgroundImage": "C:\\win10\\imgs\\WindowsTerminal\\totoro.png",

"backgroundImageAlignment": "bottomRight",

"backgroundImageOpacity": 0.3,

"backgroundImageStretchMode": "none"

}

效果如下:

7fcec139d38e

theme1.png

例如,给 WSL 设置一个 Ubuntu 主题,并且在右下角添加一个企鹅的小图片,配置如下:

{

"guid": "{c6eaf9f4-32a7-5fdc-b5cf-066e8a4b1e40}",

"hidden": false,

"name": "Ubuntu-20.04",

"source": "Windows.Terminal.Wsl",

"colorScheme": "Ubuntu",

"backgroundImage": "C:\\win10\\imgs\\WindowsTerminal\\linux.png",

"backgroundImageAlignment": "bottomRight",

"backgroundImageOpacity": 0.4,

"backgroundImageStretchMode": "none"

}

同时需要设置 schemes:

{

"name": "Ubuntu",

"black": "#2e3436",

"red": "#cc0000",

"green": "#4e9a06",

"yellow": "#c4a000",

"blue": "#3465a4",

"purple": "#75507b",

"cyan": "#06989a",

"white": "#d3d7cf",

"brightBlack": "#555753",

"brightRed": "#ef2929",

"brightGreen": "#8ae234",

"brightYellow": "#fce94f",

"brightBlue": "#729fcf",

"brightPurple": "#ad7fa8",

"brightCyan": "#34e2e2",

"brightWhite": "#eeeeec",

"background": "#300a24",

"foreground": "#eeeeec"

}

效果如下:

7fcec139d38e

theme2.png

设置 Powerline

7fcec139d38e

powerline.png

参考

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值