powershell總結

配置自動補全

安裝最新版本PSReadLine:

Install-Module PSReadLine -AllowPrerelease -Force

如果不使用上面方法安裝可能碰到錯誤:

Set-PSReadLineOption : 找找不不到到與與參參數數名名稱稱“PredictionSource”匹匹配配的的參參數數。

修改配置文件並設置從搜索歷史從補全vim $PROFILE

Import-Module PSReadLine
Set-PSReadLineOption -PredictionSource History

效果:

光標放到最後

Set-PSReadLineKeyHandler -Key UpArrow -ScriptBlock {
  [Microsoft.PowerShell.PSConsoleReadLine]::HistorySearchBackward()
  [Microsoft.PowerShell.PSConsoleReadLine]::EndOfLine()
}
Set-PSReadLineKeyHandler -Key DownArrow -ScriptBlock {
  [Microsoft.PowerShell.PSConsoleReadLine]::HistorySearchForward()
  [Microsoft.PowerShell.PSConsoleReadLine]::EndOfLine()
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章