From: "Benjamin R. Haskell" <zsh@benizi.com>
To: zsh-users@zsh.org
Subject: Re: Absolute path of a path
Date: Wed, 27 Oct 2010 12:57:32 -0400 (EDT) [thread overview]
Message-ID: <alpine.LNX.2.01.1010271253060.3583@hp> (raw)
In-Reply-To: <20101027164454.GA19471@prunille.vinc17.org>
[-- Attachment #1: Type: TEXT/PLAIN, Size: 930 bytes --]
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
prev parent reply other threads:[~2010-10-27 17:07 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-27 9:25 Nikolai Weibull
2010-10-27 9:34 ` Jérémie Roquet
2010-10-27 9:37 ` Nikolai Weibull
2010-10-27 16:44 ` Vincent Lefevre
2010-10-27 16:54 ` Jérémie Roquet
2010-10-28 10:44 ` Vincent Lefevre
2010-10-28 10:46 ` Vincent Lefevre
2010-10-28 10:52 ` Vincent Lefevre
2010-12-20 10:26 ` Vincent Lefevre
2010-12-20 14:44 ` Peter Stephenson
2010-12-25 14:43 ` Vincent Lefevre
2010-10-28 12:19 ` Jérémie Roquet
2010-10-28 13:17 ` Vincent Lefevre
2010-10-28 12:45 ` Benjamin R. Haskell
2010-10-27 16:54 ` Mikael Magnusson
2010-10-27 16:57 ` Benjamin R. Haskell [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LNX.2.01.1010271253060.3583@hp \
--to=zsh@benizi.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).