From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10866 invoked by alias); 7 Mar 2012 13:32:03 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 16860 Received: (qmail 10784 invoked from network); 7 Mar 2012 13:32:01 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,RCVD_IN_DNSWL_LOW, T_DKIM_INVALID,T_TO_NO_BRKTS_FREEMAIL autolearn=no version=3.3.2 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 209.85.213.43 as permitted sender) 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== MIME-Version: 1.0 Date: Wed, 7 Mar 2012 14:24:43 +0100 Message-ID: Subject: Ordering of alternatives for menu completion From: =?ISO-8859-1?Q?Jesper_Nyg=E5rds?= To: zsh-users@zsh.org Content-Type: text/plain; charset=ISO-8859-1 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 ", 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?