Terminal美化
效果展示
安装Chocolatey
-
如果未安装Git for Windows,请先参考 适用于 Windows 的 Git教程
-
安装Chocolatey,并使用Chocolatey安装ConEmu,通过 PowerShell安装
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
安装时出现未能解析错误,请先参考解决方案
报错示例:
iwr : 未能解析此远程名称: 'raw.githubusercontent.com' 所在位置 行:1 字符: 1 + iwr -useb get.scoop.sh | iex + ~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest],WebExce ption + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
解决方法:
# 修改host文件即可解决 # 打开以下路径 C:\Windows\System32\drivers\etc # 在最后一行后插入以下内容,保存再在powershell中执行安装choco命令 199.232.68.133 raw.githubusercontent.com # 安装完成后即可删除临时插入的内容
安装 posh-git 以及 oh-my-posh
-
使用 PowerShell,安装 Posh-Git 和 Oh-My-Posh:
Install-Module posh-git -Scope CurrentUser Install-Module oh-my-posh -Scope CurrentUser
配置PowerShell及主题
-
用 powershell 生成配置文件
# 为PowerShell生成一个自定义的Profile,用来配置PowerShell if(!(Test-Path -Path $PROFILE)) { New-Item -Type File -Path $PROFILE -Force } # 用记事本打开上面的文件,PowerShell中输入 notepad $PROFILE
# 在打开的记事本中插入以下内容并保存 Import-Module posh-git Import-Module oh-my-posh # powerlevel10k_rainbow指设置的主题名 Set-PoshPrompt -Theme powerlevel10k_rainbow
# 修改powershell的执行策略,确保上面的配置能够生效,在powershell中执行 set-executionpolicy remotesigned
字体下载
字体最终选择MesloLGSDZ NF
,用以支持powershell的oh-my-posh主题中的特殊字符
安装Windows Terminal
- 打开Microsoft Store,搜索Windows Terminal点击获取即可
配置Terminal
打开Terminal,打开配置,编辑JSON文件
将原先json文件内容清空,并粘贴以下内容
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"actions":
[
{
"command":
{
"action": "newTab"
},
"keys": "ctrl+n"
},
{
"command": "paste",
"keys": "ctrl+v"
},
{
"command": "duplicateTab",
"keys": "ctrl+shift+d"
},
{
"command":
{
"action": "closeTab"
}
},
{
"command": "closePane",
"keys": "ctrl+w"
},
{
"command": "find",
"keys": "ctrl+f"
},
{
"command":
{
"action": "copy"
},
"keys": "ctrl+c"
},
{
"command": "unbound",
"keys": "alt+-"
},
{
"command": "unbound",
"keys": "alt+plus"
},
{
"command": "unbound",
"keys": "ctrl+]"
},
{
"command": "unbound",
"keys": "ctrl+["
},
{
"command": "unbound",
"keys": "ctrl+shift+1"
},
{
"command": "unbound",
"keys": "ctrl+shift+2"
},
{
"command": "unbound",
"keys": "ctrl+shift+3"
},
{
"command": "unbound",
"keys": "ctrl+shift+4"
},
{
"command": "unbound",
"keys": "ctrl+shift+5"
},
{
"command": "unbound",
"keys": "ctrl+shift+6"
},
{
"command": "unbound",
"keys": "ctrl+shift+7"
},
{
"command": "unbound",
"keys": "ctrl+shift+8"
},
{
"command": "unbound",
"keys": "ctrl+shift+9"
},
{
"command": "unbound",
"keys": "ctrl+alt+1"
},
{
"command": "unbound",
"keys": "ctrl+alt+2"
},
{
"command": "unbound",
"keys": "ctrl+alt+3"
},
{
"command": "unbound",
"keys": "ctrl+alt+4"
},
{
"command": "unbound",
"keys": "ctrl+alt+5"
},
{
"command": "unbound",
"keys": "ctrl+alt+6"
},
{
"command": "unbound",
"keys": "ctrl+alt+7"
},
{
"command": "unbound",
"keys": "ctrl+alt+8"
},
{
"command": "unbound",
"keys": "ctrl+alt+9"
},
{
"command": "openNewTabDropdown",
"keys": "ctrl+shift+space"
},
{
"command":
{
"action": "scrollDown"
},
"keys": "ctrl+shift+down"
},
{
"command":
{
"action": "openSettings"
},
"keys": "ctrl+,"
},
{
"command":
{
"action": "nextTab"
},
"keys": "ctrl+tab"
},
{
"command":
{
"action": "prevTab"
},
"keys": "ctrl+shift+tab"
},
{
"command":
{
"action": "scrollUp"
},
"keys": "ctrl+shift+up"
},
{
"command": "scrollUpPage",
"keys": "pgup"
},
{
"command": "scrollDownPage",
"keys": "pgdn"
},
{
"command":
{
"action": "splitPane",
"split": "auto",
"splitMode": "duplicate"
},
"keys": "alt+shift+d"
}
],
"alwaysShowTabs": true,
"copyFormatting": "none",
"copyOnSelect": false,
"defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"focusFollowMouse": true,
"initialCols": 120,
"initialRows": 30,
"profiles":
{
"defaults": {},
"list":
[
{
"acrylicOpacity": 0.75,
"closeOnExit": "graceful",
"colorScheme": "Campbell",
"commandline": "powershell.exe",
"cursorColor": "#FFFFFF",
"cursorShape": "bar",
"font":
{
"face": "MesloLGSDZ NF",
"size": 14
},
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"hidden": false,
"historySize": 9001,
"name": "Windows PowerShell",
"padding": "0, 0, 0, 0",
"snapOnInput": true,
"useAcrylic": true
},
{
"acrylicOpacity": 0.65000000000000002,
"closeOnExit": "graceful",
"colorScheme": "UbuntuLegit",
"commandline": "cmd.exe",
"cursorColor": "#FFFFFF",
"cursorShape": "bar",
"font":
{
"face": "Sarasa Term SC",
"size": 13
},
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"hidden": false,
"historySize": 9001,
"name": "cmd",
"padding": "0, 0, 0, 0",
"snapOnInput": true,
"startingDirectory": "%Workspaces%",
"useAcrylic": true
},
{
"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
"hidden": false,
"name": "Azure Cloud Shell",
"source": "Windows.Terminal.Azure"
}
]
},
"schemes":
[
{
"background": "#161719",
"black": "#000000",
"blue": "#85BEFD",
"brightBlack": "#000000",
"brightBlue": "#96CBFE",
"brightCyan": "#85BEFD",
"brightGreen": "#94FA36",
"brightPurple": "#B9B6FC",
"brightRed": "#FD5FF1",
"brightWhite": "#E0E0E0",
"brightYellow": "#F5FFA8",
"cursorColor": "#FFFFFF",
"cyan": "#85BEFD",
"foreground": "#C5C8C6",
"green": "#87C38A",
"name": "Atom",
"purple": "#B9B6FC",
"red": "#FD5FF1",
"selectionBackground": "#FFFFFF",
"white": "#E0E0E0",
"yellow": "#FFD7B1"
},
{
"background": "#0C0C0C",
"black": "#0C0C0C",
"blue": "#0037DA",
"brightBlack": "#767676",
"brightBlue": "#3B78FF",
"brightCyan": "#61D6D6",
"brightGreen": "#16C60C",
"brightPurple": "#B4009E",
"brightRed": "#E74856",
"brightWhite": "#F2F2F2",
"brightYellow": "#F9F1A5",
"cursorColor": "#FFFFFF",
"cyan": "#3A96DD",
"foreground": "#CCCCCC",
"green": "#13A10E",
"name": "Campbell",
"purple": "#881798",
"red": "#C50F1F",
"selectionBackground": "#FFFFFF",
"white": "#CCCCCC",
"yellow": "#C19C00"
},
{
"background": "#012456",
"black": "#0C0C0C",
"blue": "#0037DA",
"brightBlack": "#767676",
"brightBlue": "#3B78FF",
"brightCyan": "#61D6D6",
"brightGreen": "#16C60C",
"brightPurple": "#B4009E",
"brightRed": "#E74856",
"brightWhite": "#F2F2F2",
"brightYellow": "#F9F1A5",
"cursorColor": "#FFFFFF",
"cyan": "#3A96DD",
"foreground": "#CCCCCC",
"green": "#13A10E",
"name": "Campbell Powershell",
"purple": "#881798",
"red": "#C50F1F",
"selectionBackground": "#FFFFFF",
"white": "#CCCCCC",
"yellow": "#C19C00"
},
{
"background": "#282A36",
"black": "#21222C",
"blue": "#F1FA8C",
"brightBlack": "#6272A4",
"brightBlue": "#D6ACFF",
"brightCyan": "#A4FFFF",
"brightGreen": "#69FF94",
"brightPurple": "#FF92DF",
"brightRed": "#FF6E6E",
"brightWhite": "#FFFFFF",
"brightYellow": "#FFFFA5",
"cursorColor": "#FFFFFF",
"cyan": "#8BE9FD",
"foreground": "#F8F8F2",
"green": "#50FA7B",
"name": "Dracula",
"purple": "#BD93F9",
"red": "#FF5555",
"selectionBackground": "#FFFFFF",
"white": "#F8F8F2",
"yellow": "#F1FA8C"
},
{
"background": "#1A1A1A",
"black": "#282C34",
"blue": "#61AFEF",
"brightBlack": "#5A6374",
"brightBlue": "#61AFEF",
"brightCyan": "#56B6C2",
"brightGreen": "#19A33A",
"brightPurple": "#C678DD",
"brightRed": "#E06C75",
"brightWhite": "#DCDFE4",
"brightYellow": "#E5C07B",
"cursorColor": "#FFFFFF",
"cyan": "#56B6C2",
"foreground": "#DCDFE4",
"green": "#19A33A",
"name": "Git Flat UI",
"purple": "#C678DD",
"red": "#E06C75",
"selectionBackground": "#FFFFFF",
"white": "#DCDFE4",
"yellow": "#E5C07B"
},
{
"background": "#282C34",
"black": "#282C34",
"blue": "#61AFEF",
"brightBlack": "#5A6374",
"brightBlue": "#61AFEF",
"brightCyan": "#56B6C2",
"brightGreen": "#98C379",
"brightPurple": "#C678DD",
"brightRed": "#E06C75",
"brightWhite": "#DCDFE4",
"brightYellow": "#E5C07B",
"cursorColor": "#FFFFFF",
"cyan": "#56B6C2",
"foreground": "#DCDFE4",
"green": "#98C379",
"name": "One Half Dark",
"purple": "#C678DD",
"red": "#E06C75",
"selectionBackground": "#FFFFFF",
"white": "#DCDFE4",
"yellow": "#E5C07B"
},
{
"background": "#FAFAFA",
"black": "#383A42",
"blue": "#0184BC",
"brightBlack": "#4F525D",
"brightBlue": "#61AFEF",
"brightCyan": "#56B5C1",
"brightGreen": "#98C379",
"brightPurple": "#C577DD",
"brightRed": "#DF6C75",
"brightWhite": "#FFFFFF",
"brightYellow": "#E4C07A",
"cursorColor": "#4F525D",
"cyan": "#0997B3",
"foreground": "#383A42",
"green": "#50A14F",
"name": "One Half Light",
"purple": "#A626A4",
"red": "#E45649",
"selectionBackground": "#FFFFFF",
"white": "#FAFAFA",
"yellow": "#C18301"
},
{
"background": "#002B36",
"black": "#002B36",
"blue": "#268BD2",
"brightBlack": "#073642",
"brightBlue": "#839496",
"brightCyan": "#93A1A1",
"brightGreen": "#586E75",
"brightPurple": "#6C71C4",
"brightRed": "#CB4B16",
"brightWhite": "#FDF6E3",
"brightYellow": "#657B83",
"cursorColor": "#FFFFFF",
"cyan": "#2AA198",
"foreground": "#839496",
"green": "#859900",
"name": "Solarized Dark",
"purple": "#D33682",
"red": "#DC322F",
"selectionBackground": "#FFFFFF",
"white": "#EEE8D5",
"yellow": "#B58900"
},
{
"background": "#FDF6E3",
"black": "#002B36",
"blue": "#268BD2",
"brightBlack": "#073642",
"brightBlue": "#839496",
"brightCyan": "#93A1A1",
"brightGreen": "#586E75",
"brightPurple": "#6C71C4",
"brightRed": "#CB4B16",
"brightWhite": "#FDF6E3",
"brightYellow": "#657B83",
"cursorColor": "#002B36",
"cyan": "#2AA198",
"foreground": "#657B83",
"green": "#859900",
"name": "Solarized Light",
"purple": "#D33682",
"red": "#DC322F",
"selectionBackground": "#FFFFFF",
"white": "#EEE8D5",
"yellow": "#B58900"
},
{
"background": "#000000",
"black": "#000000",
"blue": "#3465A4",
"brightBlack": "#555753",
"brightBlue": "#729FCF",
"brightCyan": "#34E2E2",
"brightGreen": "#8AE234",
"brightPurple": "#AD7FA8",
"brightRed": "#EF2929",
"brightWhite": "#EEEEEC",
"brightYellow": "#FCE94F",
"cursorColor": "#FFFFFF",
"cyan": "#06989A",
"foreground": "#D3D7CF",
"green": "#4E9A06",
"name": "Tango Dark",
"purple": "#75507B",
"red": "#CC0000",
"selectionBackground": "#FFFFFF",
"white": "#D3D7CF",
"yellow": "#C4A000"
},
{
"background": "#FFFFFF",
"black": "#000000",
"blue": "#3465A4",
"brightBlack": "#555753",
"brightBlue": "#729FCF",
"brightCyan": "#34E2E2",
"brightGreen": "#8AE234",
"brightPurple": "#AD7FA8",
"brightRed": "#EF2929",
"brightWhite": "#EEEEEC",
"brightYellow": "#FCE94F",
"cursorColor": "#000000",
"cyan": "#06989A",
"foreground": "#555753",
"green": "#4E9A06",
"name": "Tango Light",
"purple": "#75507B",
"red": "#CC0000",
"selectionBackground": "#FFFFFF",
"white": "#D3D7CF",
"yellow": "#C4A000"
},
{
"background": "#2C001E",
"black": "#4E9A06",
"blue": "#3465A4",
"brightBlack": "#555753",
"brightBlue": "#729FCF",
"brightCyan": "#34E2E2",
"brightGreen": "#8AE234",
"brightPurple": "#AD7FA8",
"brightRed": "#EF2929",
"brightWhite": "#EEEEEE",
"brightYellow": "#FCE94F",
"cursorColor": "#FFFFFF",
"cyan": "#06989A",
"foreground": "#EEEEEE",
"green": "#300A24",
"name": "UbuntuLegit",
"purple": "#75507B",
"red": "#CC0000",
"selectionBackground": "#FFFFFF",
"white": "#D3D7CF",
"yellow": "#C4A000"
},
{
"background": "#000000",
"black": "#000000",
"blue": "#000080",
"brightBlack": "#808080",
"brightBlue": "#0000FF",
"brightCyan": "#00FFFF",
"brightGreen": "#00FF00",
"brightPurple": "#FF00FF",
"brightRed": "#FF0000",
"brightWhite": "#FFFFFF",
"brightYellow": "#FFFF00",
"cursorColor": "#FFFFFF",
"cyan": "#008080",
"foreground": "#C0C0C0",
"green": "#008000",
"name": "Vintage",
"purple": "#800080",
"red": "#800000",
"selectionBackground": "#FFFFFF",
"white": "#C0C0C0",
"yellow": "#808000"
}
],
"showTabsInTitlebar": true,
"showTerminalTitleInTitlebar": true
}