Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Absolute pathnames similar to expand-cmd-path
- X-seq: zsh-users 15731
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: David Evans <david.evans@xxxxxxxxxxxx>
- Subject: Re: Absolute pathnames similar to expand-cmd-path
- Date: Tue, 25 Jan 2011 17:22:09 +0100
- Cc: zsh-users@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=NMl+nc1tFAvHVFwoTc4GBaqMSaHaV//jQxU1Y8LsxHA=; b=xiGimjcgJA04rYVbQwU+QNjTrepI2fh0p2W6UoDWkwBNBjWg6pp6xG0v0wz/899fJ9 U9QO5rAGUasyp6ooq+YdxMyEI9FpfnKNEaQYd2ytlrRe0e70vJINVh/ri3UONRSXGKIF 5RIHOAyILOHqNJPVZjBdIr7UTCo7oLVrro7rM=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=aEUdFlEKMTLB+q28y0W1I9+gAtEp7NvR/IkSJxIFqrKHsXIvkyq5nHi2KT5VRVjFf2 5GYmu4IG+EBwSrJAUyvIqj2ZRb6LpFPDxX5KtiM3iQxPGS5j4eND3NFx1048BPEDcumG xR1xSyfTBqcttAsBuk0iPqDYFxgWySWHv/TQA=
- In-reply-to: <44CE36D4-9044-4148-BDCE-636D85AC003B@cl.cam.ac.uk>
- 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: <44CE36D4-9044-4148-BDCE-636D85AC003B@cl.cam.ac.uk>
On 25 January 2011 16:56, David Evans <david.evans@xxxxxxxxxxxx> wrote:
> expand-cmd-path is a great widget. Is there a similar thing for turning the current word
> into an absolute path? Sometimes I'm typing a ../../.. chain and would like to see how far
> I've gone. This should be easy with a widget function and :a but I don't want to write it
> if even less work is needed.
I have this lying around. It shouldn't be too hard to modify it to do
what you want.
autoload -U split-shell-arguments
function _split_shell_arguments_under()
{
local -a reply
split-shell-arguments
#have to duplicate some of modify-current-argument to get the word
#_under_ the cursor, not after.
setopt localoptions noksharrays multibyte
if (( REPLY > 1 )); then
if (( REPLY & 1 )); then
(( REPLY-- ))
fi
fi
REPLY=${reply[$REPLY]}
}
function _showcurrargrealpath() {
setopt localoptions nonomatch
local REPLY REALPATH
_split_shell_arguments_under
#zle -M "$(realpath ${(Q)${~REPLY}} 2> /dev/null | head -n1 || echo
1>&2 "No such path")"
REALPATH=( ${(Q)${~REPLY}}(:A) )
zle -M "${REALPATH:-Path not found: $REPLY}"
}
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author