How to clear terminal command history in VS code? How to clear terminal command history in VS code? powershell powershell

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