
我注意到,長的多行命令不會記錄到ConsoleHost_history.txt
PowerShell 7 中(與 PowerShell 5 不同)。我怎樣才能改變這個?
答案1
雖然AddToHistoryHandler
of在 PowerShell 5 中Get-PSReadLineOption
存在$null
,但在 PowerShell 7 中卻不是。
執行以下命令將刪除處理程序,並且還會記錄長多行命令:
Set-PSReadLineOption -AddToHistoryHandler $null
若要使此變更永久生效,請將上面的行新增至您的 PowerShell 7 設定檔。設定檔的位置儲存在自動變數中$PROFILE
(您可能需要建立該檔案)。