## 1、Windows Terminal 基于 Windows PowerShell 下的窗口美化
### 1)管理员身份运行软件Windows PowerShell
打开开始菜单,输入PowerShell 已管理员身份运行
### 2)安装Chocolatey
``` shell
$ Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
```
### 3)安装Oh-my-posh
``` shell
$ choco install ConEmu
$ Install-Module posh-git -Scope CurrentUser
$ Install-Module oh-my-posh -Scope CurrentUser
```
**注:**以上内容存在需要从github上获取修改代码段的可能,建议有条件的情况下开启VPN
### 4)设置Profile脚本
```shell
# 构建配置脚本文件
$ if (!(Test-Path -Path $PROFILE )) { New-Item -Type File -Path $PROFILE -Force }
# 运用记事本打开配置文件
$ notepad $PROFILE
```
将以下内容添加到打开的文件中
> Import-Module posh-git
> Import-Module oh-my-posh
> Set-PoshPrompt -Theme Paradox
**注:** 最后一行切勿配置为**Set-Theme Paradox**
关闭脚本禁用:允许Powershell运行脚本
```sh
$ set-executionpolicy remotesigned
```
### 5)安装Windows Terminal
从 MS 商店安装 Windows Terminal

正常情况下开启后效果如下

### 6)字体安装
#### a 安装wget
在管理员身份的 Windows PowerShell 中运行以下命令
```sh
$ choco install wget
```
#### b 下载优化字体
从地址:https://github.com/adam7/delugia-code/releases/download/v1910.04.1/Delugia.Nerd.Font.Complete.ttf
下载对应优化字体安装包
#### c 配置字体
快捷键 **ctrl + Alt + ,** 打开Terminal配置文件;并在对应位置添加配置信息

添加内容到以下位置,如下图

```
"colorScheme": "Campbell",
"useAcrylic": true,
"closeOnExit": false,
"acrylicOpacity": 0.8,
"fontFace": "Delugia Nerd Font",
```
### 最终效果如下:

## 2、Windows Terminal 配置
对Windows Terminal的配置文件如下
```json
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"alwaysShowTabs": false,
"defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"initialCols": 65, // 默认列宽度
"initialRows": 20, // 默认行高度
// 快捷键
"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 https://aka.ms/terminal-selection
{
"command":
{
"action": "copy",
"singleLine": false
},
"keys": "ctrl+shift+c"
},
{
"command": "paste",
"keys": "ctrl+shift+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 https://aka.ms/terminal-panes
{
"command": {
"action": "splitPane",
"split": "vertical"
},
"keys": "alt+u" // 垂直分割窗口
},
{
"command": {
"action": "splitPane",
"split": "horizontal"
},
"keys": "alt+h" // 水平分割窗口
},
{
"command": {
"action": "splitPane",
"split": "auto",
"splitMode": "duplicate"
},
"keys": "alt+y;" // 自动分割
},
{ "command": { "action": "moveFocus", "direction": "down" }, "keys": "alt+k" },
{ "command": { "action": "moveFocus", "direction": "left" }, "keys": "alt+j" },
{ "command": { "action": "moveFocus", "direction": "right" }, "keys": "alt+l" },
{ "command": { "action": "moveFocus", "direction": "up" }, "keys": "alt+i" },
{ "command": { "action": "resizePane", "direction": "down" }, "keys": "alt+shift+k" },
{ "command": { "action": "resizePane", "direction": "left" }, "keys": "alt+shift+j" },
{ "command": { "action": "resizePane", "direction": "right" }, "keys": "alt+shift+l" },
{ "command": { "action": "resizePane", "direction": "up" }, "keys": "alt+shift+i" },
{ "command": "closeTab", "keys": "ctrl+alt+q"},
{ "command": "closePane", "keys": "ctrl+alt+w"},
{ "command": "newTab", "keys": "ctrl+alt+t" },
{ "command": { "action": "newTab", "index": 0 }, "keys": "ctrl+alt+1" },
{ "command": { "action": "newTab", "index": 1 }, "keys": "ctrl+alt+2" },
{ "command": { "action": "newTab", "index": 2 }, "keys": "ctrl+alt+3" },
{ "command": { "action": "newTab", "index": 3 }, "keys": "ctrl+alt+4" },
{ "command": { "action": "newTab", "index": 4 }, "keys": "ctrl+alt+5" },
{ "command": { "action": "newTab", "index": 5 }, "keys": "ctrl+alt+6" },
{ "command": { "action": "newTab", "index": 6 }, "keys": "ctrl+alt+7" },
{ "command": { "action": "newTab", "index": 7 }, "keys": "ctrl+alt+8" },
{ "command": { "action": "newTab", "index": 8 }, "keys": "ctrl+alt+9" },
{ "command": "nextTab", "keys": "ctrl+tab" },
{ "command": "prevTab", "keys": "ctrl+shift+tab" },
{ "command": { "action": "switchToTab", "index": 0 }, "keys": "ctrl+shift+1" },
{ "command": { "action": "switchToTab", "index": 1 }, "keys": "ctrl+shift+2" },
{ "command": { "action": "switchToTab", "index": 2 }, "keys": "ctrl+shift+3" },
{ "command": { "action": "switchToTab", "index": 3 }, "keys": "ctrl+shift+4" },
{ "command": { "action": "switchToTab", "index": 4 }, "keys": "ctrl+shift+5" },
{ "command": { "action": "switchToTab", "index": 5 }, "keys": "ctrl+shift+6" },
{ "command": { "action": "switchToTab", "index": 6 }, "keys": "ctrl+shift+7" },
{ "command": { "action": "switchToTab", "index": 7 }, "keys": "ctrl+shift+8" },
{ "command": { "action": "switchToTab", "index": 8 }, "keys": "ctrl+shift+9" },
{ "command": "togglePaneZoom", "keys": "alt+p"}
],
// You can add more global application settings here.
// To learn more about global settings, visit https://aka.ms/terminal-global-settings
// 如果启用,选择将自动复制到剪贴板
"copyOnSelect": true,
// 如果启用,格式化的数据也会复制到剪贴板
"copyFormatting": true,
"requestedTheme": "system",// 标题栏样式,system 跟随系统
"showTabsInTitlebar": true,
"showTerminalTitleInTitlebar": true,
"wordDelimiters": " ./\\()\"'-:,.;<>~!@#$%^&*|+=[]{}~?\u2502",
// 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 https://aka.ms/terminal-profile-settings
"profiles":
{
"defaults":
{
// Put settings here that you want to apply to all profiles.
},
"list":
[
{
// Make changes here to the powershell.exe profile.
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"name": "Windows PowerShell",
"commandline": "powershell.exe",
"colorScheme": "Campbell",
"useAcrylic": true,
"closeOnExit": false,
"acrylicOpacity": 0.8,
"fontFace": "Delugia Nerd Font",
"fontSize": 12,
"hidden": false
},
{
"guid": "{07b52e3e-de2c-5db4-bd2d-ba144ed6c273}",
"hidden": false,
"name": "Ubuntu-20.04",
"source": "Windows.Terminal.Wsl"
},
{
// 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 https://aka.ms/terminal-color-schemes
"schemes": [],
// Add custom actions and keybindings to this array.
// To unbind a key combination from your defaults.json, set the command to "unbound".
// To learn more about actions and keybindings, visit https://aka.ms/terminal-keybindings
"actions":
[
// 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 https://aka.ms/terminal-panes
{ "command": { "action": "splitPane", "split": "auto", "splitMode": "duplicate" }, "keys": "alt+shift+d" }
]
}
```
本文档详细介绍了如何在Windows环境下美化和配置WindowsTerminal,包括安装Chocolatey、Oh-my-posh、设置PowerShell配置文件、安装WindowsTerminal、调整字体和配置文件,以及自定义快捷键。此外,还提供了详细的配置示例,展示了最终的终端效果。
729

被折叠的 条评论
为什么被折叠?



