How to clear terminal command history in VS code?
Try the following command:
Set-PSReadlineOption -HistoryNoDuplicates
It sets the HistoryNoDuplicates
option to True
and hides duplicate histories.
You can see the value of HistoryNoDuplicates
with the following command:
(Get-PSReadLineOption).HistoryNoDuplicates
If you want to set it back to False
:
Set-PSReadlineOption -HistoryNoDuplicates:$false
For more information, see Set-PSReadlineOption in Microsoft Docs.
As a conclusion to the answers: my actual process to prevent duplicates, delete history and clear:
Set-PSReadlineOption -HistoryNoDuplicates
Remove-Item (Get-PSReadlineOption).HistorySavePath
Alt-F7
the Cmdlet Clear-History
should do what you want https://docs.microsoft.com/en-us/powershell/module/Microsoft.PowerShell.Core/Clear-History?view=powershell-6