Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Ordering of alternatives for menu completion
- X-seq: zsh-users 16860
- From: Jesper Nygårds <jesper.nygards@xxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Ordering of alternatives for menu completion
- Date: Wed, 7 Mar 2012 14:24:43 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=Bdk0xNozSZkmXfMs/rcYHPyttFZYK2FVQJXjn0EY49Q=; b=lgyTXc/qLG46KYIZ3J8JIDSQ453WFQ8M/GWfGB5oGeaUvCZY1NlQGRzMk2tORPMtj9 B7fJUGnGATQUXe//ir1iIqYvhKbqjip7YNLj8fogQrYtOBBdMAiYnHvHOIKD2KUMoTXP xEzewgdPmPVoqVb2VpANbLnW9KqBThbZcyNgZudLIjk3yMIHfpE+8t75JmO3P8UBu31Z Ore7xbPA8KDTAbbHDJQHb93qCFTjdcaEh9+sThfVarV8dUQFmupgynQe6WGckmZNYeD6 tmcsng0OSxHFjtjCLPV/mxzGVBPkYIydycTY3v7oUJGE7U1zCpKQr78SjhXF3g5MhG7L VUBw==
- 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
I use menu completion and I am trying to make a simple completion
function NOT sort the completion alternatives alphabetically.
I have a function called up(), and I am trying to add a completion
function for it, as follows:
_up() {
local myarray myindex revarray
myarray=( ${(s:/:)PWD} )
revarray=()
for myindex in {2..$(( $#myarray - 1 ))}; do
revarray=( $myarray[$myindex] $revarray[@] )
done
compadd - $revarray
}
compdef _up up
What it does is that it splits the current path into its parts, and
then reverses the array, ignoring the current directory (the last part
of the original array). So if $PWD is
"/Workbench/workspace/actual/src/main/resources", $revarray will be
"main src actual workspace Workbench".
This works fine, but when I use the completion like this: "up <tab>",
the alternatives are cycled in alphabetical order. I want them to be
suggested in the order of $revarray, i.e. with the closest parent
first and the progressively higher up in the hierarchy, but some
mechanism sorts the alternatives alphabetically.
I have experimented with different ways to indicate that I don't want
this array to be sorted, but haven't succeeded. How can I achieve
this?
Messages sorted by:
Reverse Date,
Date,
Thread,
Author