WindowTerminal 配置
最终效果图
如果是win10的话, 在Microsoft Store
安装Windows Terminal
, win11已经的话已经自带了.
PowerShell 美化
# 如果安装powershell出现 Install-Module : 找不到与参数名称“AllowPrerelease”匹配的参数,执行以下指令
Install-Module -Name PackageManagement -Repository PSGallery -Force
Install-Module -Name PowerShellGet -Repository PSGallery -Force
# 重启shell后再执行以下语句
Install-Module -Name Az.StorageSync -AllowPrerelease -AllowClobber -Force
# 安装相关模块
# 这里使用 scoop 安装
scoop install https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/oh-my-posh.json
# 更新指令
scoop update oh-my-posh
# 安装 posh-git
Install-Module posh-git -Scope CurrentUser
# Install-Module oh-my-posh -Scope CurrentUser 这种方式过时了
# 安装 PSReadLine
Install-Module -Name PSReadLine -AllowPrerelease -Scope CurrentUser -Force -SkipPublisherCheck
# 设置Profile脚本 生成脚本 Microsoft.PowerShell_profile.ps1
if (!(Test-Path -Path $PROFILE )) { New-Item -Type File -Path $PROFILE -Force }
# 打开配置文件 添加启动脚本
code $Profile
# 再配置好启动脚本后,运行以下指令预览主题, 选择一个喜欢修改名字即可
Get-PoshThemes
Import-Module posh-git
#oh-my-posh init pwsh | Invoke-Expression
# 初始化时指定主题
# oh-my-posh --init --shell pwsh --config "$env:POSH_THEMES_PATH\{主题名称}.omp.json" | Invoke-Expression
oh-my-posh --init --shell pwsh --config "$env:POSH_THEMES_PATH\thecyberden.omp.json" | Invoke-Expression
# 设置主题
# 该方式已经过时
# Set-PoshPrompt -Theme powerlevel10k_classic
# 打预测历史记录 推荐打开, 方便不少, 效果如下图
Set-PSReadLineOption -PredictionSource History
Set-PSReadlineKeyHandler -Key Tab -Function Complete # 设置 Tab 键补全
Set-PSReadLineKeyHandler -Key "Ctrl+d" -Function MenuComplete # 设置 Ctrl+d 为菜单补全和 Intellisense
Set-PSReadLineKeyHandler -Key "Ctrl+z" -Function Undo # 设置 Ctrl+z 为撤销
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward # 设置向上键为后向搜索历史记录
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward # 设置向下键为前向搜索历史纪录
# 关闭脚本禁用,允许运行脚本
# set-executionpolicy remotesigned
# 配置 vim
Set-Alias vim "D:\Tools\vim\vim82\vim.exe"
Function Edit-Profile
{
vim $profile
}
Function Edit-Vimrc
{
vim $HOME\_vimrc
}
打开powershell
历史记录的效果
然后管理员的方式打开ps,修改默认的执行权限
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
安装字体
# 管理员方式启动,然后按照提示选择即可
oh-my-posh font install
WindowTerminal 配置文件
以下是profile
文件的内容. 可以使用pw的new-guid
指令生成guid
来配置setting.
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"actions": [],
"defaultProfile": "{8c7a4479-9589-4545-a389-6edc21acf791}",
"profiles":
{
"defaults": {},
"list":
[
{
"acrylicOpacity": 0.80000000000000004,
"background": "#333333",
"backgroundImageOpacity": 0.10000000000000001,
"closeOnExit": "graceful",
"commandline": "D:\\Programs\\PowerShell-7.1.4-win-x64\\pwsh.exe -nologo",
"experimental.retroTerminalEffect": false,
"font":
{
"face": "Delugia Nerd Font",
"size": 12,
"weight": "normal"
},
"foreground": "#16AB10",
"guid": "{8c7a4479-9589-4545-a389-6edc21acf791}",
"hidden": false,
"historySize": 9001,
"icon": "D:\\Programs\\PowerShell-7.1.4-win-x64\\assets\\StoreLogo.png",
"name": "PowerShell",
"snapOnInput": true,
"startingDirectory": null,
"useAcrylic": true
},
{
"acrylicOpacity": 0.80000000000000004,
"background": "#333333",
"backgroundImageOpacity": 0.10000000000000001,
"font":
{
"face": "Delugia Nerd Font",
"size": 12
},
"guid": "{07b52e3e-de2c-5db4-bd2d-ba144ed6c273}",
"hidden": false,
"name": "Ubuntu-20.04",
"source": "Windows.Terminal.Wsl",
"tabTitle": "WSL",
"useAcrylic": true
},
{
"acrylicOpacity": 0.80000000000000004,
"background": "#333333",
"backgroundImageOpacity": 0.10000000000000001,
"commandline": "wsl.exe -d Debian",
"font":
{
"face": "Delugia Nerd Font",
"size": 12
},
"guid": "{e55e28e3-8944-477f-a7fd-279f179b5539}",
"hidden": false,
"icon": "ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png",
"name": "Debian",
"tabTitle": "WSL",
"useAcrylic": true
},
{
"acrylicOpacity": 0.80000000000000004,
"background": "#333333",
"backgroundImageOpacity": 0.10000000000000001,
"closeOnExit": "graceful",
"commandline": "D:\\cygwin\\Cygwin.bat",
"font":
{
"face": "Delugia Nerd Font",
"size": 12
},
"foreground": "#16AB10",
"guid": "{0656c823-4c83-087d-77ed-922e5c3780ae}",
"hidden": false,
"icon": "D:\\cygwin\\Cygwin.ico",
"name": "Cygwin",
"snapOnInput": true,
"startingDirectory": null,
"tabTitle": "Cygwin",
"useAcrylic": true
},
{
"background": "#333333",
"backgroundImageOpacity": 0.10000000000000001,
"closeOnExit": "graceful",
"commandline": "D:/Application/Scoop/apps/msys2/current/msys2_shell.cmd -msys -defterm -no-start",
"font":
{
"face": "Delugia Nerd Font",
"size": 12
},
"foreground": "#16AB10",
"guid": "{dbb6c7c1-db83-4a56-92fa-18ae938888e2}",
"hidden": false,
"icon": "D:/Application/Scoop/apps/msys2/current/msys2.ico",
"name": "Msys2",
"snapOnInput": true,
"startingDirectory": null,
"tabTitle": "Msys2"
},
{
"acrylicOpacity": 0.80000000000000004,
"background": "#333333",
"backgroundImageOpacity": 0.20000000000000001,
"closeOnExit": "graceful",
"commandline": "powershell.exe",
"font":
{
"size": 10
},
"foreground": "#16AB10",
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"hidden": false,
"name": "Windows PowerShell",
"snapOnInput": true,
"startingDirectory": null,
"useAcrylic": true
},
{
"background": "#333333",
"backgroundImageOpacity": 0.10000000000000001,
"closeOnExit": "graceful",
"commandline": "cmd.exe",
"font":
{
"size": 10
},
"foreground": "#16AB10",
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"hidden": false,
"name": "CMD",
"snapOnInput": true,
"startingDirectory": null
},
{
"guid": "{2ece5bfe-50ed-5f3a-ab87-5cd4baafed2b}",
"hidden": false,
"name": "Git Bash",
"source": "Git"
}
]
},
"schemes":
[
{
"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": "#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": "#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"
}
],
"tabWidthMode": "equal"
}