Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Absolute path of a path
- X-seq: zsh-users 15510
- From: "Benjamin R. Haskell" <zsh@xxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Absolute path of a path
- Date: Wed, 27 Oct 2010 12:57:32 -0400 (EDT)
- In-reply-to: <20101027164454.GA19471@xxxxxxxxxxxxxxxxxxx>
- 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: <AANLkTikZN2Lk3zf2fWqD917TA-Wa5jCBQSZ-7VNWVOCj@xxxxxxxxxxxxxx> <AANLkTi=j_OtAziY1X=1qj=zk3P7=U6my1sd=bVshp69u@xxxxxxxxxxxxxx> <20101027164454.GA19471@xxxxxxxxxxxxxxxxxxx>
On Wed, 27 Oct 2010, Vincent Lefevre wrote:
On 2010-10-27 11:34:44 +0200, JÃrÃmie Roquet wrote:
2010/10/27 Nikolai Weibull>:
How do I get the absolute path of a path? ÂThe only thing I can find
is the :a modifier for history expansion.
your_path(:a)
For example .(:a) is pwd
BTW, is there a way to get the canonicalised absolute pathname with
zsh? (i.e. what the "realpath" command gives.)
With new enough Zsh, you can use: the ':A' modifier.
As a workaround, though, since I have to use older Zsh'es on various
systems, I have:
# uses Perl, since that tends to be more consistent than 'realpath'
# across the systems I was using this on:
A () { reply=("$(perl -MCwd=realpath -we 'print realpath shift' $REPLY)") }
Then, instead of:
your_path(:A) -- returns the realpath in new Zsh'es.
you can do:
your_path(+A) -- calls the 'A' function above to find the realpath
--
Best,
Ben
Messages sorted by:
Reverse Date,
Date,
Thread,
Author