zsh-users
 help / color / mirror / code / Atom feed
From: "Jesper Nygårds" <jesper.nygards@gmail.com>
To: zsh-users@zsh.org
Subject: Re: Resolving absolute path of named directory
Date: Tue, 22 Jan 2013 11:58:44 +0100	[thread overview]
Message-ID: <CABZhJg8zN5pOZnLHowxUpu+rXm3JzwhbWRdm3xfhE=RzBNDP6g@mail.gmail.com> (raw)
In-Reply-To: <20130122101440.GA8372@picard.franken.de>

[-- Attachment #1: Type: text/plain, Size: 1263 bytes --]

On Tue, Jan 22, 2013 at 11:14 AM, Thomas Köhler
<jean-luc@picard.franken.de>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.

  reply	other threads:[~2013-01-22 10:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-22  8:50 Jesper Nygårds
2013-01-22 10:14 ` Thomas Köhler
2013-01-22 10:58   ` Jesper Nygårds [this message]
2013-01-22 19:45     ` Peter Stephenson
2013-01-23 19:19       ` Peter Stephenson

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='CABZhJg8zN5pOZnLHowxUpu+rXm3JzwhbWRdm3xfhE=RzBNDP6g@mail.gmail.com' \
    --to=jesper.nygards@gmail.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).