![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| | |||||||
| | Vista - FEATURE REQUEST: better history support |
| |
| 08-11-2006 | #1 |
| | FEATURE REQUEST: better history support The incremental history search (Ctrl-R, Ctrl-S) in bash is VERY nice and we need it in PowerShell. I wrote a function 'last' to attempt something similar, but it's not nearly as good. We need support for this from within the line editor. # runs the last command in the history that matches the given regular expression. # TODO: it'd be nice if this was closer to bash's excellent Ctrl-R support # examples: # last submit # run, eg, a recent "sd submit -c xxx" command # last "sdp pack" # run, eg, a recent "sdp pack" command function last($match) { $local:items = (get-history) for($local:i=$items.length-1; $i -gt 0; $i--) { $local:hi = $items[$i] if($hi.commandLine -match $match) { $local:cl = $hi.commandLine # exclude other 'last' commands unless the match explicitly contained 'last' # TODO: this is dumb because by making assumptions about the name, it prevents users # from effectively aliasing the function. it should be more like bash's Ctrl-R support if($cl.startsWith("last ") -and !$match.contains("last")) { continue } if($cl.length -gt 40) { $cl = $cl.substring(0, 40) + "..." } $local:input = (read-host "Run '$cl' [Yes/No/Quit]?").toLower() if($input -eq "y" -or $input -eq "yes") { invoke-history $hi.ID return } elseif($input -eq "q" -or $input -eq "quit") { return } } } echo "No matches." } |
| My System Specs |
| 08-11-2006 | #2 |
| | Re: FEATURE REQUEST: better history support "Adam Milazzo [MSFT]" <adamm@san.rr.com> wrote in message news:%236h0U7avGHA.2260@TK2MSFTNGP03.phx.gbl... > The incremental history search (Ctrl-R, Ctrl-S) in bash is VERY nice and > we need it in PowerShell. The built-in history feature of the console is OK. Try typing in the first part of a command that you entered before and press F8 (keep pressing F8) for more matches. You can also press F7 to get a character mode window of the history. Certainly not as powerful as a regex search engine but still quite useful. -- Keith |
| My System Specs |
| 08-11-2006 | #3 |
| | Re: FEATURE REQUEST: better history support Keith Hill [MVP] wrote: > "Adam Milazzo [MSFT]" <adamm@san.rr.com> wrote in message > news:%236h0U7avGHA.2260@TK2MSFTNGP03.phx.gbl... >> The incremental history search (Ctrl-R, Ctrl-S) in bash is VERY nice >> and we need it in PowerShell. > > The built-in history feature of the console is OK. Try typing in the > first part of a command that you entered before and press F8 (keep > pressing F8) for more matches. You can also press F7 to get a character > mode window of the history. Certainly not as powerful as a regex search > engine but still quite useful. F8, huh? That's not too bad. Although it'd be better if it wasn't a prefix, but an arbitrary substring. (Often many commands start the same.) It'd also be better if I didn't have to move my hand too far. By the way, how did you find out about this? I don't remember reading about it in the user guide... Thanks, -- Adam |
| My System Specs |
| 08-12-2006 | #4 |
| | Re: FEATURE REQUEST: better history support > By the way, how did you find out about this? I don't remember reading > about it in the user guide... F7, F8 and etc. are standard features of windows console, not PowerShell. Try cmd.exe and you will see the same. -- Thanks, Roman |
| My System Specs |
![]() |
| Thread Tools | |
| |
| Similar Threads for: FEATURE REQUEST: better history support | ||||
| Thread | Forum | |||
| Why I think the help & support feature is the best feature on Windows Vista. | Vista networking & sharing | |||
| feature request | Vista General | |||
| feature request | Vista General | |||