一、PowerShell美化
1.安装新款 PowerShell
用管理员模式打开刚装好的新版 powershell,依次安装以下软件
# 更改执行策略
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
# 查看当前执行策略
# Get-ExecutionPolicy -Scope CurrentUser
2.安装 PSReadLine
install-module -Name PSReadLine -AllowPrerelease -Force
PSReadLine 是一个由微软发布的用于 PowerShell 的行读取实现,提供了以下功能:
- 语法着色
- 简单语法错误通知
- 良好的多行体验
- 可自定义的键绑定
- Cmd 和 Emacs 模式
- 许多配置选项
- Bash 样式的补全
- Bash/zsh 样式的交互式历史记录搜索
- Emacs yank/kill ring
- 基于 PowerShell Token 的单词移动和删除
- 撤销 / 重做
- 自动保存历史记录,包括在实时会话中共享历史记录
- 菜单补全、Intellisense
3.安装 oh-my-posh
Install-Module oh-my-posh -Scope CurrentUser
# 卸载
# Uninstall-Module oh-my-posh -AllVersions
oh-my-posh 为 PowerShell 提供了很多自定义主题和配色
4.安装posh-git
install-module posh-git -Scope CurrentUser
# 卸载
# Uninstall-Module posh-git -AllVersions
posh-git 为 PowerShell 提供了 git 状态显示和命令补全等
5.执行以下命令编辑 PowerShell 配置文件
notepad.exe $Profile
#这个文件会在 PowerShell 启动的时候自动执行,因此我们在这个文件中加载我们所需的模块。
#导入需要的模块
Import-Module posh-git
Import-Module oh-my-posh
#设置主题
Set-Theme Honukai
#新版的 oh-my-posh 将 Set-Theme 指令修改为了 Set-PoshPrompt 命令
#可选主题如下
#Agnoster,Avit,Darkblood,Fish,Honukai,Paradox,PowerLine,robbyrussell,Sorin,tehrob
6.安装需要的字体(否则会出现乱码)
(1)下载需要的字体
(2)安装字体
将下载好的字体(一般为 *.ttf 文件复制到 C:\Windows\Fonts 文件夹下)
二、美化 Windows Terminal
1.设置默认打开 新版 powershell
Windows Terminal 默认为旧版本的 powershell,我们需要把新版本作为默认打开应用
2.设置 windows Terminal 的主题
3设置 windows Terminal 的字体
将 windows terminal 的字体设置为你新安装的字体