Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Neat hash -d trick
- X-seq: zsh-users 15474
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: Neat hash -d trick
- Date: Fri, 22 Oct 2010 16:24:21 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s1024; t=1287757462; bh=6RDM8dntG8Mc8wX8C6gc2hHCqY7DZjkPf5rhN4cW3LI=; h=Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:Received:In-reply-to:From:References:To:Subject:Date:Message-ID; b=Cm7QnU0956udJiYFuX10NlaEAUl4jKxSuLtX6KRJLXq/Pj2Oyu0B5TdjwqQoLcRuVmUSxKiaOT35R/cwx+n5ZgtVkHPl7Stx17rc76etjZdOBYWx9nHGyYLEIaKy0Fey3HZB1nzWeMHKeCnylYIU/7xwB1uIEP/g/trH1PEJXO4=
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.co.uk; h=DKIM-Signature:Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:Received:In-reply-to:From:References:To:Subject:Date:Message-ID; b=pBOBLzTPayPMxU5Gj8MFlp4H/orBFfLfwwdLVEluFPTAQ+sXITEQ64kN0jee74lMIBj2L57pxJgyLbqiWc319adCP86i5YddqoMapyfE5bjf0TFIbDioYdxMiadORAPaibvwFLXiIcKaH2XAHuMuFsTF4/gUl/nc/M61PFs8FHc= ;
- In-reply-to: <101021210513.ZM30802@xxxxxxxxxxxxxxxxxxxxxx>
- 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: <AANLkTikBOSBNfBHXDFdfiCkijVt5G5+-1UVFz_VqY3wZ@xxxxxxxxxxxxxx> <101021210513.ZM30802@xxxxxxxxxxxxxxxxxxxxxx>
Bart wrote:
> A similar trick:
[snip]
> Now you can type ESC 4 . to insert ../../../.. (or ESC 9 ESC 9 . to
> insert 99 levels, if for some insane reason you need that many).
If you find counting the directories harder than doing it interactively
on the screen we could try using menu selection. This splits either the
path currently on the command-line or $PWD if that's empty into
directory components and then does menu selection with them in a packed
list.
zle -C up-dir reverse-menu-complete _generic
zstyle ':completion:up-dir::::' completer _up-dir
bindkey '^X\e[A' up-dir
And _up-dir contains:
#compdef -k reverse-menu-complete ^X\e[A
local -a dirs
local -a dest
compset -P '*[=:]'
compset -S ':*'
if [[ $compstate[context] = tilde ]]; then
PREFIX="~$PREFIX"
IPREFIX=${IPREFIX%\~}
fi
dirs=( ${(s./.)${~PREFIX:-$PWD}} )
for f in $dirs; do
dest+=${dest[-1]}/$f
done
PREFIX=
compstate[list]=packed
compadd -V dirs -d dirs -f -qS/ -a dest
I'm not sure if that's depending on further styles I have but you should
be able to get the idea. I can't remember how to make menu selection
really do reverse-menu-complete and give me the last completion to begin
with. It clears off anything up to and equals or colon in the current
word and includes a hack for the tilde context. I was also trying to
remember if there was a way to separate the completion matches with a
slash instead of spaces but I don't think there is.
Oliver
Messages sorted by:
Reverse Date,
Date,
Thread,
Author