Mike Fletcher | 24 Jul 16:17

History expansion to rerun multiple contiguous commands?

Is there a way to use bang notation to re-run a chunk of a shell's 
history?  As an example I've got 4 commands numbered 123-126 in my 
history and I want to (in one swell foop) rerun all 4.

I know worst case I can manually type out "!123 ; !124 ; !125 ; !126" 
but that seems . . . inelegant.

I tried a couple of quick tricks building that expansion by hand and 
then passing it to eval but that doesn't want to seem to do the 
necessary history expansion.

Thanks in advance.

Peter Stephenson | 24 Jul 16:25
Favicon

Re: History expansion to rerun multiple contiguous commands?

Mike Fletcher wrote:
> Is there a way to use bang notation to re-run a chunk of a shell's 
> history?  As an example I've got 4 commands numbered 123-126 in my 
> history and I want to (in one swell foop) rerun all 4.

Not with bang notation, but you can use "r 123 126" to do this.

--

-- 
Peter Stephenson <pws <at> csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070

Paul Lew | 24 Jul 18:54
Favicon

Re: History expansion to rerun multiple contiguous commands?

>>>>> "Peter" == Peter Stephenson <pws <at> csr.com> writes:

    Mike>> Is there a way to use bang notation to re-run a chunk of a
    Mike>> shell's history?  As an example I've got 4 commands
    Mike>> numbered 123-126 in my history and I want to (in one swell
    Mike>> foop) rerun all 4.

    Peter> Not with bang notation, but you can use "r 123 126" to do
    Peter> this.

I do the following almost everyday (with emacs binding), for example:

    vi foo.c
    gcc foo.c
    a.out

    vi <alt-p>
    vi foo.c <ctrl-o>
    gcc foo.c <ctrl-o>
    a.out <ctrl-o>  or <return>

After the a.out, I type: vi <alt-p> which binds to
history-beginning-search-backward which will bring 'vi foo.c' on the
command line.  Then I type ctrl-o which binds to
accept-line-and-down-history to execute the 'vi foo.c' command and the
shell will bring up the next command in history 'gcc.foo.c', further
ctrl-o will continue walk the history.

If you replace foo.c with $i and put i=foo.c on top, you can then
repeat the commands by changing the file name, this is my perferred
(Continue reading)

zzapper | 28 Jul 13:10

Re: History expansion to rerun multiple contiguous commands?


Hi
Dont know if this Helps

!! ; !-2 ; !-3; !23
great thing is that you repeat above with
!!

--

-- 
zzapper
http://www.successtheory.com/tips/vimtips.html
http://www.successtheory.com/tips/zshtips.html


Gmane