Shift+Space 在 Powershell 中不起作用

Shift+Space 在 Powershell 中不起作用

自從更新到 Windows 10 v1809 以來,Shift+Space在 Powershell v5 中按不再傳送空格。如果我使用較舊的 Windows 10 工作站 (v1709),Shift+Space則會傳送一個空格。

例如,我習慣按以下按鍵順序:

g,,,,, .ciShift+Space|

在 v1803 中,這將導致gci |.在 v1809 中,結果是gci|.

這個組合鍵與最近推出的組合鍵是否衝突?該問題在多個站點上都可以重現。如果我在文字編輯器中工作,則問題不存在。啟動 PS-NoProfile沒有任何影響。

此外,這僅影響我安裝 PS 5.1。當我安裝PS Core 6.0.2時,Shift+Space仍然會傳送空格。

答案1

看來您需要更新PowerShellGet模組PSReadLine才能shift+space再次工作。

  1. 以管理員身分開啟 PowerShell
  2. 跑步install-module -name powershellget -force
  3. 重新啟動 PowerShell(以管理員身分)
  4. 跑步install-module -name psreadline -allowprerelease -force
  5. 再次重新啟動 PowerShell

這應該可以,並且應該可以再次工作。

來源:https://www.reddit.com/r/sysadmin/comments/9n9mh0/powershell_51_shiftspace_problem/

答案2

這似乎在 PowerShell 5.1.x 中再次被「破壞」。也就是說,Get-PSReadLineKeyHandler不顯示與 關聯的映射Shift+Spacebar,並且按 Shift+空格鍵沒有任何效果。

明確啟用它可以Set-PSReadLineKeyHandler -Chord Shift+Spacebar -Function SelfInsert修復問題(按 Shift+空白鍵插入空格字元),但映射不會Get-PSReadLineKeyHandler按原樣顯示在列表中,而是顯示為普通Space映射。

相關內容