Skip to content

Instantly share code, notes, and snippets.

@d-e-v-esh
Last active October 2, 2022 19:36
Show Gist options
  • Save d-e-v-esh/88ca42499dd9b4f196dd33eda5191e30 to your computer and use it in GitHub Desktop.
Save d-e-v-esh/88ca42499dd9b4f196dd33eda5191e30 to your computer and use it in GitHub Desktop.
# set PowerShell to UTF-8
[console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding
# Icons
Import-Module -Name Terminal-Icons
# Posh Theme
oh-my-posh init pwsh --config 'C:/Users/Devesh/devesh.omp.json' | Invoke-Expression
Set-PSReadlineOption -PredictionSource History
Get-PSReadlineOption | % PredictionSource
# Shows navigable menu of all options when hitting Tab
# Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
# Autocompletion for arrow keys
Set-PSReadLineOption –HistoryNoDuplicates:$True
Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward
$PSReadLineOptions = @{
# EditMode = "Vi"
HistoryNoDuplicates = $true
HistorySearchCursorMovesToEnd = $true
Colors = @{
"Command" = "#fe8019"
}
}
Set-PSReadLineOption @PSReadLineOptions
# Keeps short and simple commands out of history
$addToHistoryHandler = {
Param([string]$line)
if ($line.Length -le 3) {
return $false
}
if (@("exit","dir","ls","pwd","cd ..", "yarn").Contains($line.ToLowerInvariant())) {
return $false
}
return $true
}
Set-PSReadlineOption -AddToHistoryHandler $addToHistoryHandler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment