PowerShell美化
PowerShell 美化
安装oh-my-posh
Install-Module oh-my-posh -Scope CurrentUser -SkipPublisherCheck
安装 posh-git
Install-Module posh-git -Scope CurrentUser
安装 Terminal-Icons
Install-Module -Name Terminal-Icons -Repository PSGallery
打开 PowerShell 配置文件
notepad $PROFILE
配置以下内容:
Import-Module posh-git
Import-Module oh-my-posh
Import-Module Terminal-Icons
Set-PoshPrompt -Theme Paradox
oh-my-posh --init --shell pwsh --config D:/oh-my-posh/themes/powerlevel10k_rainbow.omp.json | Invoke-Expression
安装 PSReadLine
Install-Module PSReadLine -AllowPrerelease -Scope CurrentUser -Force -SkipPublisherCheck
开启命令行自动补全和提示
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
设置预测命令颜色
Set-PSReadLineOption -Colors @{ InlinePrediction = "#C0C0C0" }
配置 PSReadLine
notepad $PROFILE
添加以下内容
Import-Module PSReadLine
Set-PSReadLineOption -PredictionSource History
Set-PSReadLineOption -Colors @{ InlinePrediction = "#C0C0C0" }
安装 scoop 包管理工具
修改PowerShell的安全策略
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
安装 scoop
iex (new-object net.webclient).downloadstring('https://raw.githubusercontent.com/lukesampson/scoop/master/bin/install.ps1')
测试是否安装成功
scoop help
安装 busybox
busybox 内置了Linux的许多命令,可以在windows上使用
scoop install busybox
安装 starship
scoop install starship
在 PROFILE 文件中添加
Invoke-Expression (&starship init powershell)
在 .config/starship.toml 中添加
# 设置配置范例,开启编辑器的自动补全
"$schema" = 'https://starship.rs/config-schema.json'
# 在命令之间插入空行
add_newline = true
# 将提示符的“❯”替换为“➜”
[character] # “character”是我们正在配置的组件
success_symbol = "[➜](bold green)" # 设置“success_symbol” 字段为绿色加粗的“➜”
# 禁用 package 组件,完全隐藏它的提示符
[package]
disabled = true