如何在 PowerShell Core 中啟用語法反白?

如何在 PowerShell Core 中啟用語法反白?

我最近安裝了PowerShell核心透過巧克力口味

我新安裝的 PowerShell Core 沒有語法突出顯示(下面螢幕截圖中的紅色圓圈),也沒有\在自動完成目錄時附加反斜線(下面螢幕截圖中的藍色圓圈)。

新的 PowerShell Core 與舊的 PowerShell

如何在新的 PowerShell Core 中啟用這兩個功能?

答案1

  1. 開啟您的 PowerShell 設定檔(例如~\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
  2. 追加行Import-Module PSReadLine

如果您使用多種鍵盤佈局並安裝了 PSReadLine 版本 2.0.0,由於這個錯誤,您需要安裝最新測試版和:

Install-Module -Name PSReadLine -RequiredVersion 2.0.0-beta5 -AllowPrerelease

文件:

相關內容