手把手教你美化微软的新终端Windows Terminal

网友投稿 2064 2022-09-15

手把手教你美化微软的新终端Windows Terminal

手把手教你美化微软的新终端Windows Terminal

1. 前言

微软的新终端​Windows Terminal​终于发布正式版了。这个终端诞生以来就大获好评,对于使用​Windows​进行开发的小伙伴来说又有了新的玩具了。先来看看官方的介绍视频吧。

接着胖哥教大家如何去美化这个终端,把它打造成时尚的开发利器。

2. 安装

安装非常简单,通过​Microsoft Store​可以轻松安装​Windows Terminal​。

Microsoft Store 安装 Windows Terminal

3. 安装美化主题

打开​PowerShell​安装Oh-My-Posh​[1]​和Posh-Git​[2]​

Set-ExecutionPolicy BypassInstall-Module posh-git -Scope CurrentUserInstall-Module oh-my-posh -Scope CurrentUser

​Posh-Git​将​Git​状态信息添加到提示,并为​Git​命令、参数、远程和分支名称添加 tab 自动补全。​Oh-My-Posh​为​PowerShell​提示符提供主题功能。

如果使用的是​PowerShell Core​,请安装​PSReadline​:

Install-Module -Name PSReadLine -Scope CurrentUser -Force -SkipPublisherCheck

然后​PowerShell​命令行执行:

if (!(Test-Path -Path $PROFILE )) { New-Item -Type File -Path $PROFILE -Force }notepad $PROFILE

会打开如下记事本,将下面的代码配置到记事本中保存:

Import-Module posh-gitImport-Module oh-my-poshSet-Theme Paradox

配置PowerShell

当然你可以在命令行中执行 ​​Get-Theme​​ 列出所有的样式:

列出所有样式

然后使用​​Set-Theme 名称​​来预览你想要的风格,然后替换上面的记事本对应的样式名称即可。

4. 安装 Powerline 字体

​Powerline​提供自定义的命令提示符体验,提供​Git​状态颜色编码和提示符,不然很多符号都是乱码。

Windows 终端 Powerline PowerShell

推荐到我的​Git​仓库-,地址为自定义配置

打开Windows Terminal 配置

按照上图打开配置是一个​json​文件,这里我贴一下我的配置,你抄就是了:

{ "$schema": " "defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}", // You can add more global application settings here. // To learn more about global settings, visit // If enabled, selections are automatically copied to your clipboard. "copyOnSelect": false, // If enabled, formatted data is also copied to your clipboard "copyFormatting": false, // A profile specifies a command to execute paired with information about how it should look and feel. // Each one of them will appear in the 'New Tab' dropdown, // and can be invoked from the commandline with `wt.exe -p xxx` // To learn more about profiles, visit "profiles": { "defaults": { // Put settings here that you want to apply to all profiles. "colorScheme": "Banana Blueberry", "background": "#191323", //背景颜色,PS默认为蓝色 "closeOnExit": true, //关闭窗口的时候退出所有挂载的程序 "commandline": "powershell.exe", //此处终端打开PS "cursorColor": "#FFFFFF", //光标颜色 "cursorShape": "bar", //光标形状(默认为bar,即条状) "fontFace": "DejaVu Sans Mono for Powerline", "fontSize": 12, "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}", //唯一标识符,随机生成 "historySize": 9001, //缓存大小 "icon": "ms-appx:///ProfileIcons/{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.png", //图标 "name": "PowerShell", //在下拉菜单里显示的名称 "tabTitle": "PowerShell", //在选项卡上显示的名称 "padding": "0, 0, 0, 0", //内容的边框距,默认填充全部空间 "snapOnInput": true, //输入的时候自动滚动到输入位置 "startingDirectory": "%USERPROFILE%" //初始工作目录,默认为用户目录 }, "list": [ { // Make changes here to the powershell.exe profile. "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}", "name": "Windows PowerShell", "commandline": "powershell.exe", "hidden": false }, { // Make changes here to the cmd.exe profile. "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}", "name": "命令提示符", "commandline": "cmd.exe", "hidden": false }, { "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}", "hidden": false, "name": "Azure Cloud Shell", "source": "Windows.Terminal.Azure" } ] }, // Add custom color schemes to this array. // To learn more about color schemes, visit "schemes": [ { "name": "Monokai Night", "background": "#1f1f1f", "foreground": "#f8f8f8", "black": "#1f1f1f", "blue": "#6699df", "cyan": "#e69f66", "green": "#a6e22e", "purple": "#ae81ff", "red": "#f92672", "white": "#f8f8f2", "yellow": "#e6db74", "brightBlack": "#75715e", "brightBlue": "#66d9ef", "brightCyan": "#e69f66", "brightGreen": "#a6e22e", "brightPurple": "#ae81ff", "brightRed": "#f92672", "brightWhite": "#f8f8f2", "brightYellow": "#e6db74" }, { "name": "Banana Blueberry", "black": "#17141f", "red": "#ff6b7f", "green": "#00bd9c", "yellow": "#e6c62f", "blue": "#22e8df", "purple": "#dc396a", "cyan": "#56b6c2", "white": "#f1f1f1", "brightBlack": "#495162", "brightRed": "#fe9ea1", "brightGreen": "#98c379", "brightYellow": "#f9e46b", "brightBlue": "#91fff4", "brightPurple": "#da70d6", "brightCyan": "#bcf3ff", "brightWhite": "#ffffff", "background": "#191323", "foreground": "#cccccc" } ], // Add custom keybindings to this array. // To unbind a key combination from your defaults.json, set the command to "unbound". // To learn more about keybindings, visit "keybindings": [ // Copy and paste are bound to Ctrl+Shift+C and Ctrl+Shift+V in your defaults.json. // These two lines additionally bind them to Ctrl+C and Ctrl+V. // To learn more about selection, visit { "command": { "action": "copy", "singleLine": false }, "keys": "ctrl+c" }, { "command": "paste", "keys": "ctrl+v" }, // Press Ctrl+Shift+F to open the search box { "command": "find", "keys": "ctrl+shift+f" }, // Press Alt+Shift+D to open a new pane. // - "split": "auto" makes this pane open in the direction that provides the most surface area. // - "splitMode": "duplicate" makes the new pane use the focused pane's profile. // To learn more about panes, visit { "command": { "action": "splitPane", "split": "auto", "splitMode": "duplicate" }, "keys": "alt+shift+d" } ]}

如果你想修改字体找到​​fontFace​​配置​Powerline​字体;如果你要修改配色方案,找到​​schemes​​​数组后将配色方案添加进去即可,激活参考上面的配置将 ​​schemes[i].name​​​的值填写到​​profiles.defaults.colorScheme​​保存重启终端即可。

这里推荐一个​Windows Terminal​配色方案的​Github​项目Windows Terminal Themes​[3]​

Windows Terminal Themes

其它什么透明、毛玻璃、背景图的操作,网上有很多教程,过于简单这里就不提了。更多的配置可参考Windows Terminal 官方文档​[4]​

6. 添加 Windows Terminal 到右键菜单

Windows Terminal添加到右键菜单

文中引用

[1]

Oh-My-Posh: ​​Terminal Themes: ​Terminal官方文档: ​https://docs.microsoft.com/zh-cn/windows/terminal/​

​​​​

如果文章对您有用请转发让更多人看到。​

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:汇编语言程序设计学习笔记(第一遍学习)-第1节:机器语言编程到汇编语言的
下一篇:ROS2初学者教程(Dashing和Eloquent)Windows
相关文章

 发表评论

暂时没有评论,来抢沙发吧~