总所周知,Windows默认的终端非常难看且不好用,本文介绍使用Windows Terminal+nerd-fonts+Oh my posh+PSReadLine 实现终端的美化字体样式和自动补全。
在Chocolatey Software | Installing Chocolatey网页下,复制安装脚本
安装脚本
shellSet-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
复制到终端中
即可自动安装Chocolatey
推荐使用等宽连体带图标(终端显示的花样多一点)的字体
我使用Nerd Fonts
安装使用Chocolatey
即可
bashchoco install nerd-fonts-hack
这里很多人都会去下载一个powershell,其实没有必要,Windows自带的powershell的版本和功能已经可以满足要求。
当然也可以直接使用配置文件,"defaults"
在"profiles"
属性下
json"defaults":
{
"backgroundImage": null,
"colorScheme": "Campbell",
"cursorShape": "filledBox",
"experimental.retroTerminalEffect": false,
"font":
{
"face": "CodeNewRoman Nerd Font Mono",
"size": 14.0,
"weight": "normal"
},
"opacity": 90,
"padding": "0",
"scrollbarState": "hidden",
"useAcrylic": false
},
其余的配置文件内容
json"copyFormatting": "none",
"copyOnSelect": false,
"defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"alwaysOnTop": false,
"alwaysShowTabs": true,
"autoHideWindow": false,
"disableAnimations": false,
"firstWindowPreference": "defaultProfile",
"focusFollowMouse": false,
"initialCols": 88,
"initialPosition": "750,350",
"initialRows": 24,
"launchMode": "focus",
大概在这个行数
添加快捷键
json"actions":
[
{
"command":
{
"action": "copy",
"singleLine": false
},
"keys": "ctrl+c"
},
{
"command": "paste",
"keys": "ctrl+v"
},
{
"command":
{
"action": "splitPane",
"split": "auto",
"splitMode": "duplicate"
},
"keys": "alt+shift+d"
},
{
"command": "find",
"keys": "ctrl+shift+f"
},
{
"command": "toggleFocusMode",
"keys": "alt+z"
}
],
这样可以使用alt+z
打开标题栏
没有这个选项的更新即可
Chocolatey
bashchoco install oh-my-posh
powershell
配置文件bashif (!(Test-Path -Path $PROFILE )) { New-Item -Type File -Path $PROFILE -Force }
bashnotepad $PROFILE
oh-my-posh
配置文件,其中~/.omp.theme.json
是配置文件的所在路径,windows的话就是在C:\Users\Administrator
下创建.omp.theme.json
文件并写入配置即可bashoh-my-posh init pwsh --config ~/.omp.theme.json | Invoke-Expression
使用kushal
主题,其他主题在这里选择Themes | Oh My Posh
复制内容粘贴到配置文件中即可
-nologo
项即可输入这个命令即可
bashset-ExecutionPolicy RemoteSigned
PowerShellGet
bashInstall-Module -Name PowerShellGet -Force Exit
PSReadLine
bashInstall-Module PSReadLine -AllowPrerelease -Force
powsershell
输入bashnotepad.exe $PROFILE
bashSet-PSReadLineKeyHandler -Key Tab -Function MenuComplete #Tab键会出现自动补全菜单
Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward
# 上下方向键箭头,搜索历史中进行自动补全
powershell
即可本文作者:peepdd864
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!