layout: post
win10 PowerShell 优化
subtitle: win10 PowerShell 优化 date: 2020-10-10 author: BY header-img: img/post-bg-kuaidi.jpg catalog: true tags: - PowerShell - oh-my-posh
win10 PowerShell 优化,只是美化
下载 PowerShell
https://github.com/PowerShell/PowerShell/releases
oh-my-posh美化
windows直接下载安装install-amd64.exe
# 会安装可执行文件和主题
C:\Program Files (x86)\oh-my-posh\bin\oh-my-posh.exe
C:\Program Files (x86)\oh-my-posh\themes\多个主题文件.omp.json
# 编辑文件
code $PROFILE
# 增加一行即可,我使用amro主题
oh-my-posh init pwsh --config "C:\Program Files (x86)\oh-my-posh\themes\amro.omp.json" | Invoke-Expression
字体
# 推荐下载字体nerd-fonts
https://github.com/ryanoasis/nerd-fonts/releases/tag/v2.1.0
# 如下载FiraCode.zip使用字体名称:FuraCode NF
starship美化
# https://github.com/starship/starship/releases
# 下载starship-x86_64-pc-windows-msvc.zip,解压到变量环境:
code $PROFILE
# 增加
Invoke-Expression (&starship init powershell)
starship在gitbash里面使用
# C:\Program Files\Git\bin\bash.exe
code ~/.bashrc
eval "$(C:/starship.exe init bash)"
bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'
# 配置文件在
~/.config/starship.toml
优化提示符
PowerShell 智能提示PSReadLine
# 安装
Install-Module PSReadLine -AllowPrerelease -Force
# 编辑文件
code $PROFILE
# 增加
Import-Module PSReadLine
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 # 设置向下键为前向搜索历史纪录
- 提示 无法加载 PSReadline 模块。控制台在未使用 PSReadline 的情况下运行。
- 管理员运行, 版本是2.2.6
Set-ExecutionPolicy Unrestricted
Import-Module 'C:\Program Files\WindowsPowerShell\Modules\PSReadline\2.2.6\PSReadline.psd1'
在gitbash里面使用
code ~/.bashrc
eval "$(D:/work/posh/oh-my-posh.exe --config "D:/work/posh/amro.omp.json" init bash)"
# 提示历史
bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'