iT邦幫忙

0

PowerShell 使用 PSReadLine 模組

PowerShell的PSReadLine模組可用來輔助PowerShell來做到類似zsh的效果:根據命令列歷史提示自動完成,以及可用方向鍵在選單式介面選擇候選命令/路徑的功能。
在PowerShell v7.2之後已經內建PSReadLine,不必額外指令安裝,你只需要在PowerShell的Profile檔案內加入下面這段:

Import-Module PSReadLine

# Shows navigable menu of all options when hitting Tab
Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete

# Autocompleteion for Arrow keys
Set-PSReadLineOption -HistorySearchCursorMovesToEnd
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward

Set-PSReadLineOption -ShowToolTips

之後開啟PowerShell視窗就可以使用,其他例如預測字串顏色之類的微調可參考微軟PowerShell開發團隊的部落格文章:
https://devblogs.microsoft.com/powershell/psreadline-2-2-6-enables-predictive-intellisense-by-default/


圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言