Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Ordering of alternatives for menu completion

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} )
  for myindex in {2..$(( $#myarray - 1 ))}; do
      revarray=( $myarray[$myindex] $revarray[@] )
  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

Messages sorted by: Reverse Date, Date, Thread, Author