does anybody knows of a way to have the backward command search feature of bash [Ctrl-r] (and [Ctrl-o]) that are so useful, in windows powershell ?

C-r is a more powerful arrow up history manipulation, it is like emacs's C-r in that it searches backward inside the commands you previously entered. Then C-o executes that command and immediately places on the line the next command after that. So that you can repeat passed series of commands efficiently. Also it looks up into a saved history, not a session history. (~/.bash_history file). Which is infinitely useful.


ps: as a bonus the tab completion not working by cycles would be awsome also.

  • What does ctrl O do that you want to replicate? More info us always good... – Austin T French Nov 18 '13 at 12:45
  • Yep, edited the question :) – v.oddou Nov 19 '13 at 1:37
  • 2
    I don't believe that this feature is supported. PowerShell 3 does have a hook called PSConsoleHostReadline that could be useful. A good place to start would be to use PSReadLine, which uses that hook. PSReadLine doesn't support ctrl-o, but it does support ctrl-r (supposedly -- it didn't work for me). I may have a look at implementing ctrl-o over Christmas because it does sound useful. – dangph Nov 21 '13 at 0:08
  • 2
    Ah, PSReadLine, this seems like my answer, you should post it as an answer. it does not have C-o but it has C-r which is the most important. It also has the tab completion tweak that I wanted in bonus. – v.oddou Nov 21 '13 at 2:56
  • 2
    PSReadline author here - @v.oddou - Ctrl+K should be bound to KillLine in Emacs mode. Ctrl+R should work w/ or w/o typing something first. I'm happy to add Ctrl+O - feel free to open an issue on github. – Jason Shirk Nov 27 '13 at 22:29

Type first letters of the command and press F8.

Alternatively you can press F7 and type first letters.

More details: http://technet.microsoft.com/en-us/magazine/ff678293.aspx

  • F7 does nothing... – wildeyes Jun 10 '16 at 10:47
  • Could you provide more information? May be it could be useful for others. Which version of Powershell and which version of Windows? The default Powershell is quite limited. It's better to use MobaXterm or ConEmuMaximus 5 to get better UX – georgik Aug 28 '16 at 17:36
  • @CatBoss F7 works in cmd – phuclv May 10 '17 at 13:38
  • 1
    @LưuVĩnhPhúc then the answer needs to say so, because the question is about Powershell.... – wildeyes May 10 '17 at 14:31
  • See the answer below - don't waste your time with F8 if you are on powershell 5+ – Nicholas DiPiazza Oct 17 '18 at 16:14

WMF 5.0 RTM, which includes Windows PowerShell 5, now supports the same reverse command search feature of bash CTRL+R. I have been using this in Windows 10 Anniversary Edition, and my bash muscle memory is very happy.

The support actually comes from the PowerShell module PSReadLine which I see was mentioned in some of the comments of the question. The good thing is that PSReadLine now appears to be included in the base WMF 5.0 installation, at least it is on Windows 10.

If you are running PowerShell 3 or later, you can also install PSReadLine as well and get the history search feature.

Note: I've not found out how to get this working in ISE as CTRL+R is mapped to something else (Show/Hide Script Pane).


To manipulate your history you may use the history cmdlets, list them by this command:

Get-Command *-history

Searching your history is done like this, feel free to make a function to shorten it:

Get-history | Select-String "command"

function f ($Name) { Get-history | Select-String $name }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.