Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: http://grml.org/zsh/zsh-lovers.html
- X-seq: zsh-users 16249
- From: Micah Elliott <micah@xxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: http://grml.org/zsh/zsh-lovers.html
- Date: Mon, 15 Aug 2011 13:00:08 -0700
- In-reply-to: <CADjGqHur3Q_K7ihbE2wO-OLKK4npQPdhxjn=7i2AxN_=P8B_Ng@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CADjGqHur3Q_K7ihbE2wO-OLKK4npQPdhxjn=7i2AxN_=P8B_Ng@mail.gmail.com>
- Sender: mde@xxxxxxxxxxxxxxxx
On Mon, Aug 15, 2011 at 12:28 PM, TJ Luoma <luomat@xxxxxxxxx> wrote:
> Even some things like:
>
> $f:e = file extension
> $f:h = head (dirname)
> $f:t = tail (basename)
> $f:r = rest (extension removed)
>
> The number of times I've called `basename` or used `sed` to get a
> file's extension…
Oh, I REALLY love these. I use them all the time now, in various ways.
Also great that they usually don't require the {}s.
There's a nice mnenoic that works for these -- I use ERTH (like Earth).
ER: Extension, Remove
TH: Tail, Head (instead of basename/dirname which I've always hated)
Some (slightly contrived) use cases:
% something foo.png
% other !$:r # foo
% cp somefile.html /other/place/foo.html
% cd !$:h
[[ $myfile:e == xml ]] ...
print "
usage: $0:t ..."
Chaining is also really cool:
service=$script:t:r
word=${${1:t:r}/-clip/}
There are tons of other places where I've replaced use of
dirname/basename.
--
twitter:@Membean | email:Micah@xxxxxxxxxxx | http://Membean.com
Remember your words with Membean! Three free days of learning!
Messages sorted by:
Reverse Date,
Date,
Thread,
Author