![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Repeating previous commands Is there anything in Power Shell that is equivalent to the exclamation (!) feature in bash? Here's an example. Let's say I'm working on a Python script: edit the script, run the script, repeat. Using PowerShell PS C:\> vim foo.py PS C:\> python foo.py running foo.py... done PS C:\> vim foo.py PS C:\> python foo.py running foo.py... done Using bash $ vim foo.py $ python foo.py running foo.py... done $ !v vim foo.py $ !p python foo.py running foo.py... done Using bash, I can just type !v and !p to run the last command that started with a v or p ("vi foo.py", "python foo.py"). In PowerShell, I type out the full command. Is there anything like the ! in Power Shell? It may seem like a small detail, but when working on software development projects for hours at a time, it adds up. |
| | #2 (permalink) | ||||||||||||
| Guest | Re: Repeating previous commands <snorble@xxxxxx> wrote in message news:2a9a37a9-56bf-4bc4-996b-567cc70ec1eb@xxxxxx
F7 (but not in Graphical PS?) However, since your example involves only a pair of commands you could get the same result with fewer keystrokes simply by using CursorUp twice. And that works in either app. <eg> --- | ||||||||||||
| | #3 (permalink) | ||||||||||||
| Guest | Re: Repeating previous commands snorble@xxxxxx wrote:
function r! ($pattern) { get-history | where-object { $_.CommandLine -like "$pattern" } | foreach-object { invoke-history $_ -confirm } } If you're brave, remove the -confirm. You'll need to insert asterisks, or you could add them to the pattern string. Or you could use -match for a regex. Might be overkill. -- Author, Tech Prosaic blog (http://halr9000.com) Webmaster, Psi (http://psi-im.org) Community Director, PowerShellCommunity.org Co-host, PowerScripting Podcast (http://powerscripting.net) | ||||||||||||
| |
| |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| updates repeating | chinga69 | Windows Updates | 18 | 06-07-2008 08:29 PM |
| repeating user name and password | gerda | Vista mail | 0 | 03-14-2008 01:20 PM |
| Keyboard continuously repeating | Man In Problem | Vista hardware & devices | 1 | 11-09-2007 03:59 PM |
| KB924125 update REPEATING | PA | Vista General | 0 | 11-08-2006 01:04 AM |
| repeating a windows update KB924125 | =?Utf-8?B?c2FoYXJhIHBvb2xz?= | Vista General | 0 | 10-06-2006 05:18 AM |