git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [QUERY] How do you sort completions?

From
SZEDER Gábor <szeder@ira.uka.de>
Date
May 24, 2013, 16:12 UTC
Message-ID
<20130524161243.GB2104@goldbirke>
In-Reply-To
<CALkWK0k=nVHOBe5SgRH9xQK1+yAYBzbNMqsWxhYPo0MTZPp63g@mail.gmail.com>
Hi,
On Fri, May 24, 2013 at 05:03:27PM +0530, Ramkumar Ramachandra wrote:
Show 10 quoted lines
> I'm not able to sort completions for some weird reason.  No matter
> what I order I insert stuff into COMPREPLY, bash seems to auto-sort
> them lexically.  I tried to pass --sort='-committerdate' to git
> for-each-ref so I can get a sensible 'git checkout <TAB>' reply, and
> I'm very annoyed that it doesn't work.
> 
> I thought it was bash's complete builtin doing the implicit sorting,
> so I read the manual with no success.  Is readline doing it?  If so,
> why am I not getting the ordering even in zsh (which doesn't use
> readline)?

The order of elements in COMPREPLY doesn't matter, it will be sorted anyway:

$ _foo () { COMPREPLY=("foo" "bar" "baz") ; } $ complete -F _foo foo $ foo <TAB> bar baz foo

I don't know who does the sorting (Bash or readline), and I don't know any way to disable it.

Gábor
Previous: SZEDER GáborNext: Ramkumar Ramachandra
Message 4 of 8 in “[QUERY] How do you sort completions?”
  1. Ramkumar RamachandraMay 24, 2013
  2. Felipe ContrerasMay 24, 2013
  3. SZEDER GáborMay 28, 2013
  4. SZEDER GáborMay 24, 2013
  5. Ramkumar RamachandraMay 24, 2013
  6. Antoine PelisseMay 24, 2013
  7. Ramkumar RamachandraMay 24, 2013
  8. Marc KhouzamMay 24, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.