Have a function to allow interactive search of history showing multiple matches
Currently, you can use history search function, but it only shows one line that currently matches. Would be interesting to have a menu complete type experience where it shows you a bunch of matches you can scroll through
PSFzf provides a good experience like this.
Currently, you can use history search function, but it only shows one line that currently matches. Would be interesting to have a
menu completetype experience where it shows you a bunch of matches you can scroll through
It would be a nice feature (similar to the old F7 command in cmd.exe), though I've always got pretty good mileage out of:
#searchTerm<tab>
to cycle through commands in history that match the term.
It doesn't bring them all up at once like menu complete but still pretty useful. If I really want to see a bunch of similar commands, I can always use Get-History piped to a where clause.
FWIW...
@SteveL-MSFT, what if the search results where displayed similar to ListView in Predictive IntelliSense and could be selected? Another thought - with the historical predictor already producing similar results, is enhancing the search function still needed?
@MatthewSteeves Get-History doesn't look at the history file, so isn't an option in this case. Same thing with #searchTerm
You could do something similar to Get-History by using the following.
[Microsoft.PowerShell.PSConsoleReadLine]::GetHistoryItems() | Where-Object { $_.CommandLine -match '<searchTerm>' }
But that won't get the original request, it just lets you search the history programmatically and see multiple results. The results don't let you pick from them, just see them. But I still find it useful if I know there will be a lot of matches.
@FireInWinter Thanks for pointing out - wasn't aware of the difference.