Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
select command from history and execute
select history wuth peco and set command line to execute this.
Set-PSReadLineKeyHandler -chord Ctrl+p -scriptBlock { SelectandExecHistory }
using above that hit ctrl+p to use this.
function global:SelectandExecHistory()
$selectCmd = (tail -20 (Get-PSReadLineOption).HistorySavePath)|peco --select-1 --on-cancel error
if ($?) {
# [Microsoft.PowerShell.PSConsoleReadLine]::EndOfLine()
# [Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()
} else {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment