Created
June 2, 2021 01:55
-
-
Save dipu-bd/9c31b5b02410a182824bd896f5a26a49 to your computer and use it in GitHub Desktop.
PowerShell Config for autocompletion and persisting history
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Shows navigable menu of all options when hitting Tab | |
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete | |
# Autocompletion for arrow keys | |
Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward | |
Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward | |
#Save Command History | |
$HistoryPath = 'C:\Users\Dipu\Documents\WindowsPowerShell\History' | |
If (Test-Path "${HistoryPath}\History.csv") { | |
Import-Csv "${HistoryPath}\History.csv" | Add-History | |
} ElseIf (!(Test-Path $HistoryPath)) { | |
New-Item -Path $HistoryPath -ItemType Directory | |
} | |
Register-EngineEvent -SourceIdentifier powershell.exiting -SupportEvent -Action {Get-History | Select-Object -Last 10000 | Export-Csv -Path "${HistoryPath}\History.csv"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Create new profile if not exists:
Open profile to edit: