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

Re: history expansion



On Sep 25, 12:33pm, Roman Neuhauser wrote:
} Subject: history expansion
}
} is there a setopt (or another way) that would allow me to do stuff like
} this:
} 
}     % !!:s/!!3/!-2:s,foo,bar,/
} 
} without the need to use variables?

So what you want to do is, take the entire line from two commands earlier,
do a foo -> bar replacement in that, and then use that as the replacement
for the third argument of the immediately preceding command?

I'd type C-p C-a M-f M-f M-f M-d !-2:s,foo,bar, and hit enter.

There isn't any option or other setting that allows history expansions to
be nested in that way.  The best you can do is to expand each reference as
you go along, by using magic-space or a completion binding; e.g. the above
could be obtained by typing something like

	!!3/!-2:s,foo,bar/<TAB><C-a>!!:s/<RET>

(Replace control-a with escape shift-i for vi mode.  Hmm, I guess that one
might require csh_junkie_history, too.)

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   



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