Skip to content

Instantly share code, notes, and snippets.

@trapezoid
Last active February 27, 2022 04:08
Show Gist options
  • Save trapezoid/5c824599f58f1b00f41487c51c41fe13 to your computer and use it in GitHub Desktop.
Save trapezoid/5c824599f58f1b00f41487c51c41fe13 to your computer and use it in GitHub Desktop.
PSReadLine2.2のPredictionViewStyleをCtrl+rで切り替えていい感じに使う
Set-PSReadLineOption -PredictionSource History -PredictionViewStyle InlineView
Set-PSReadLineKeyHandler -Key "Ctrl+f" -Function ForwardWord
function Switch-PredictionView()
{
if ((Get-PSReadLineOption).PredictionViewStyle -eq "InlineView")
{
Set-PSReadLineOption -PredictionViewStyle ListView
Set-PSReadLineKeyHandler -Key "Ctrl+f" -Function HistorySearchForward
Set-PSReadLineKeyHandler -Key "Ctrl+b" -Function HistorySearchBackward
}
else
{
Set-PSReadLineOption -PredictionViewStyle InlineView
Set-PSReadLineKeyHandler -Key "Ctrl+f" -Function ForwardWord
}
}
Set-PSReadLineKeyHandler -Chord "Ctrl+r" -ScriptBlock { Switch-PredictionView }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment