软件安装
- Windows 默认自带的 PowerShell 版本太低,很多功能和模块缺失,安装最新 PowerShell 以体验最佳效果。
Oh My Posh是一个自定义提示引擎,此处用于提供自定义主题。Terminal-Icons是一个 PowerShell 模块,用于在终端中显示文件、文件夹图标。
我们需要为最新版 PowerShell 安装模块,因此先切换到最新版环境再安装。winget install Microsoft.PowerShell
pwsh
winget install JanDeDobbeleer.OhMyPoshInstall-Module -Name Terminal-IconsInstall-Module PSReadLine -RequiredVersion 2.2.5
配置
```code $PROFILE
amro.json 为 oh-my-posh 主题,需手动下载 https://ohmyposh.dev/docs/themes
oh-my-posh prompt init pwsh —config C:/Users/Loong/Documents/PowerShell/amro.json | Invoke-Expression Import-Module Terminal-Icons设置预测文本来源为历史记录
Set-PSReadLineOption -PredictionSource History Set-PSReadLineOption -PredictionViewStyle ListView
每次回溯输入历史,光标定位于输入内容末尾
Set-PSReadLineOption -HistorySearchCursorMovesToEnd
设置 Tab 为菜单补全和 Intellisense
Set-PSReadLineKeyHandler -Key “Tab” -Function MenuComplete
设置 Ctrl+d 为退出 PowerShell
Set-PSReadlineKeyHandler -Key “Ctrl+d” -Function ViExit
设置 Ctrl+z 为撤销
Set-PSReadLineKeyHandler -Key “Ctrl+z” -Function Undo
设置向上键为后向搜索历史记录
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
设置向下键为前向搜索历史纪录
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward
<a name="RruoR"></a>## 配置字体marcduiker需要 [Nerd Font](https://www.nerdfonts.com/font-downloads),我使用的是`CaskaydiaCove NF`,在Windows Terminal的配置文件中,添加全局字体配置:
“defaults”: { “font”: { “face”: “CaskaydiaCove NF” } }
为了能够让vscode终端也拥有同样的显示效果,在字体设置多添加一个配置`'CaskaydiaCove NF'`
```json
"editor.fontFamily": "'Jetbrains Mono', 'CaskaydiaCove NF'"
