版权声明:本文为博主 sigmarising 原创文章,未经博主允许不得转载。 https://blog.csdn.net/sigmarising/article/details/90763423
美化 PowerShell
1. 准备工作
Step1. 下载并安装 PowerShell Core(pwsh),可在 Github 页面 进行下载。
PowerShell Core 相比传统 PowerShell 优势很多,此处推荐安装
Step2. 确保 Windows 版本在 v1903 之上(可以运行 winver
进行查看)
Windows10 在 1903 版本之后,带来了全新的 conpty,解决了原本 winpty 的大量 bug
Step3. 安装 VSCode 以及 PowerLine fonts
2. 安装 PowerShell 模块
以管理员运行 PowerShell,并执行命令:
Install-Module posh-git -Scope CurrentUser
Install-Module oh-my-posh -Scope CurrentUser
(可选)安装预览版 PSReadLine:
Install-Module -Name PSReadLine -AllowPrerelease -Scope CurrentUser -Force -SkipPublisherCheck
3. 创建启动配置文件
执行命令:
if (!(Test-Path -Path $PROFILE )) { New-Item -Type File -Path $PROFILE -Force }
notepad $PROFILE
编辑并保存如下内容:
chcp 65001
Import-Module posh-git
Import-Module oh-my-posh
Set-Theme Agnoster
4. 配置 Pwsh 字体和主题颜色
启动 pwsh,可从标题栏右键 > 属性中配置字体,建议使用 PowerLine 字体。
在 Microsoft/Terminal 仓库 中,可以下载到 ColorTool 工具,其可以应用 iTerm2-Color-Schemes 仓库 中的主题配色。
使用方法为:
./colortool -b $THEME_FILE
接下来在标题栏右键 > 属性,之后什么都不用做,直接点击确定,就可以把当前控制台和默认控制台的配色方案进行切换。
5. VSCode 内置终端
需要配置终端的 shell 和字体:
另外,需要启用 Conpty: