Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Resolving absolute path of named directory
- X-seq: zsh-users 17601
- From: Jesper Nygårds <jesper.nygards@xxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Resolving absolute path of named directory
- Date: Tue, 22 Jan 2013 11:58:44 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=PAbB+dnvG55hsgKZqnh1ELaN7b35B3wzXVi9mP4zVrM=; b=RR+yC2ne3mnjzSTedlyv5GGeyoEXmepWjSW2jJ+8kpA2HmrdDIUCZTi32qZXJ52paW qEm/6cM+nI/to8YZLVVrqsuxaNTa0FONnvLKBlpHlObIIUBDVjDfqk+jwwf1Rbj6AQPi 4rckZ+ATwtoKIWgs2XqDpbi/qutk3yaOPRh0Oyr+PU2LI25pB3NJIAylJjw6bRrNNS/Q 74+xpAqXqCbaP7NKKIbGmNYphoShUqz8nZuMaTMzGLkGf1BwisB7nNALLoMFD3bIjBC9 oXQVBPuEeoHCbGDQZfFCLVRJFK2cJnfflxKOThSe54/IHVOWHmGcvl/4qx7PvHOqfSeW s9sg==
- In-reply-to: <20130122101440.GA8372@picard.franken.de>
- 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: <CABZhJg9s03XqHkxgehAF+pVsZHfwz+0tw5T7jyLc8uM0=_LNNA@mail.gmail.com> <20130122101440.GA8372@picard.franken.de>
On Tue, Jan 22, 2013 at 11:14 AM, Thomas Köhler
<jean-luc@xxxxxxxxxxxxxxxxx>wrote:
> I expect what you want is not
> % pr=~/projects
> % mydir="~pr"
> but
> % pr=~/projects
> % mydir="$pr"
> instead. Or you might want
> % mydir=~/projects
> % print ${mydir:a}
>
>
Thank you for your help, Thomas, but I believe my example obscured what I
am trying to do, so I will try to clarify with a better example. Consider
this zle widget that I believe I have picked up from this list:
current-argument-absolute-path() {
modify-current-argument '$ARG:a'
}
zle -N current-argument-absolute-path
bindkey '\e+' current-argument-absolute-path
As its name implies, it takes the current word on the command line, and
replaces it with its corresponding absolute path. However, it does not work
for named directories. If I write ls ~<\e+> when standing in, say,
/usr/lib, it expands the "~" to "/usr/lib/~", not "/home/jesper". And the
same for named directories that I have defined myself. So my question is,
can I rewrite this function so that if what's on the command line is a
named directory, it is expanded into its correct absolute path? And I still
want it to work for arguments that are not named directories, of course.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author