Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Tip of the day: previous command output
- X-seq: zsh-users 7885
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh-users List <zsh-users@xxxxxxxxxx>
- Subject: Re: Tip of the day: previous command output
- Date: Thu, 19 Aug 2004 08:20:17 -0700 (PDT)
- In-reply-to: <20040819085812.GL22962@localhost>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20040819085812.GL22962@localhost>
- Reply-to: zsh-users@xxxxxxxxxx
On Thu, 19 Aug 2004, Jesper Holmberg wrote:
> The motivation for the following snippet is the fact that I often do a
> 'find' or a 'locate' to find some files I'm interested in, and then want
> to do some action on one of the files I just found.
[...]
> What this does is that it repeats the previous command, saving the output
> in a string.
I use this little function [*] for a similar purpose:
keep () {
kept=() # Erase old value in case of error on next line
kept=($~*)
print -Rc - $kept
}
alias keep='noglob keep '
Note that "kept" is deliberately not declared local.
E.g. I might do
patch < zsh-workers_NNNN.diff
keep **/*.(orig|rej)
emacs ${${kept:#*.orig}:r}
rm $kept
That way I don't have to redo the possibly-expensive recursive glob twice;
the result is all stashed in $kept where I can manipulate the file names
and pick out the ones I want to work on.
I haven't bothered to combine it with a completion key because I hardly
ever want one specific file or its unmodified name; I almost always end up
typing some kind of parameter substitution expression.
[*] OK, I'm fibbing. I actually call it "show" but there's an MH command
by that name that zsh may try to do completion for, so I changed the name
for public consumption.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author