Clear Saved Windows Command History (PowerShell + VS Code Step-by-Step)

#command history#Powershell#command line
Clear Saved Windows Command History (PowerShell + VS Code Step-by-Step)
  1. Windows Powershell History Path
powershell
C:\Users\user\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine
  1. Clear VS Code Trusted Folders
plaintext
1) Press Ctrl + Shift + P.
2) Type and select, Workspace: Manage Workspace Trust
3) A panel will open — click "Manage Trusted Folders" 
  1. Clear Command Palette History
powershell
Go to Settings>@tag:workspaceTrust
Click prompt always.
To get pop up of trust or not always everytime.

# Clear VS Code Command Palette History (PowerShell Script)

$vsCodeUserPath = "$env:APPDATA\Code\User\globalStorage"

# Define the main state database files that store history
$filesToDelete = @(
    "state.vscdb",
    "state.vscdb.backup"
)

# Delete the files if they exist
foreach ($file in $filesToDelete) {
    $filePath = Join-Path $vsCodeUserPath $file
    if (Test-Path $filePath) {
        Remove-Item $filePath -Force
        Write-Output "Deleted: $filePath"
    } else {
        Write-Output "Not found: $filePath"
    }
}

Write-Output "VS Code Command Palette history cleared."

# Optional: Restart VS Code
# Start-Process "code"
  1. Clear Recently Opened Folders
plaintext
1) Press Ctrl + Shift + P(on Windows)
2) In the Quick Open bar that shows up,type in "Clear Recently Opened".
3) You can either restart VS code now or choose to continue using it