Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

thanks.

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

share|improve this question
    
What does ctrl O do that you want to replicate? More info us always good... – AthomSfere Nov 18 '13 at 12:45
    
Yep, edited the question :) – v.oddou Nov 19 '13 at 1:37
1  
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
1  
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

share|improve this answer
    
F7 does nothing... – Agafada Em Jun 10 at 10:47

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 }
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .