In bash I can do Ctrl+R and start typing a command to have it search my history.
How do I do that in powershell?
Is there a way to bind a key to something like?
function GH($str) {get-history | select-string $str}
But I would need to re-read the string for each char input or removed to output matching commands like Ctrl+R does.
Is this possible?
You can fix this by adopting the PSReadLine module.
See an article on the Hey, Scripting Guy! blog regarding this bash inspired readline implementation for PowerShell.
In particular, the usage of Ctrl+Alt+(Shift)+? to show all keybindings.
Ctrl+R
Ctrl+Alt+(Shift)+S
In short: either install this module by hand or upgrade to Windows PowerShell v5.
Type your search term and then press F8, this will search your command history.
There's a very useful list of PowerShell shortcuts here.
I don't know when this got added, but on my non-customized, updated, Windows 10, it's built in. Hit ctrl+r for reverse history search, it works great.
There's also graphical search under F7 key. When pressed it will show popup which you can scroll to search for command which was executed earlier. Pressing enter while cursor hover the line will reexecute it again.
You can also start your command by putting a # character in front of the partial search text of the command you are looking for, then press tap afterwards (multiple times if necessary) to search through session history.