Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Widget of the day: expand absolute path
- X-seq: zsh-users 18534
- From: m0viefreak <m0viefreak.cm@xxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Widget of the day: expand absolute path
- Date: Fri, 28 Feb 2014 19:19:06 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=72lLg3Mb+uH7SFKs62glENrgsuGRVSpEGrVB8XKMVpc=; b=DzHpPAkcyZIbHd4txKgVUKJiAJPB/vuj9EQC7/sKOwW+ymO5KLFarNjWdWCeXlHlSG 5Md7cOZqNCfgx3E5UvS67qKw0CgKkn97SRlDTaPTtVi5uYtdz4FeH/zswajlqQWnEcfj jy6iQ4lCOaUyDjNe6ZSE9oRqcNYSJ/XqHXgRx96mH/22sV9GTR+W+uK/fbjbnTpaYQ/V iMCRwPvZ3abSegcmdXZIN0QI6Qw1ekj+nyWo5COM6CSGguJ4L7hsDMBUwVjIfzwSjqYE SfyRv5ENrG0PzY9tpigVBJos3LjGhOh6sI3e1dcgQxuyF47XhgxEBr6kRTO26bX78Hv3 ZOvg==
- In-reply-to: <20140228125601.7ba0d4ca@pwslap01u.europe.root.pri>
- 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: <20140228125601.7ba0d4ca@pwslap01u.europe.root.pri>
> Sometimes I want to expand the name of a file on the command line to its
> absolute path with all symbolic links removed, e.g. because I know the
> symbolic link is volatile. I can do that with glob qualifiers, but if
> I'm likely to want to refer to the file in the ZLE history, or I want to
> edit the path to refer to a related file in the resulting target path,
> it's quite convenient to expand it immediately. This widget does that.
Thank you! This is very useful.
But there is a small problem when executing it on a word that does not
actually match any file. It will print an error message and clear out
the word completely.
I suggest the following change:
@@ -10,7 +10,8 @@ autoload -Uz modify-current-argument
if (( ! ${+functions[glob-expand-absolute-path]} )); then
glob-expand-absolute-path() {
local -a files
- files=(${~1}(:A))
+ files=(${~1}(N:A))
+ (( $#files )) || return
REPLY=${(D)files[1]}
}
fi
Messages sorted by:
Reverse Date,
Date,
Thread,
Author