Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: History expansion to rerun multiple contiguous commands?



>>>>> "Peter" == Peter Stephenson <pws@xxxxxxx> 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
way to edit lots of different files without writing a script first.

Lots of time this is simpler than using the history number.  This is a
good old ksh trick and not sure how many people are using this.

					-- Paul  07/24/08  09:43 AM --



Messages sorted by: Reverse Date, Date, Thread, Author