modules #
常用模块介绍。
PSReadline #
提供改进的命令行编辑体验。
安装:
ps1
# PowerShell默认自带低版本PSReadLine,强制安装最新版本:
Install-Module PSReadLine -Force
配置:
ps1
#Import-Module PSReadLine
$PSReadLineOptions = @{
# Simulate Bash or Emacs
EditMode = "Emacs"
# PredictionViewStyle = "ListView"
HistoryNoDuplicates = $true
HistorySearchCursorMovesToEnd = $true
# AddToHistoryHandler = {
# Param([string]$line)
# if ($line -match "^git") {
# return $false
# } else {
# return $true
# }
# }
}
Set-PSReadLineOption @PSReadLineOptions
Set-PSReadlineKeyHandler -Chord Tab -Function MenuComplete
常用操作:
ps1
# 显示历史记录文件路径
(Get-PSReadlineOption).HistorySavePath
# 编辑器打开历史记录文件
notepad (Get-PSReadlineOption).HistorySavePath
# 查看键位绑定
Get-PSReadLineKeyHandler
Posh-Git #
命令提示符添加Git仓库信息。
安装:
ps1
Install-Module Posh-Git -Scope CurrentUser
配置:
ps1
Import-Module Posh-Git
OhMyPosh #
命令提示符美化。
安装:
ps1
winget install JanDeDobbeleer.OhMyPosh
配置:
ps1
TODO