[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: programmable completion: completing filenames with default Readline

From: Chet Ramey
Subject: Re: programmable completion: completing filenames with default Readline behavior
Date: Tue, 01 Oct 2013 16:35:00 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.0

On 9/27/13 3:57 AM, Jeremy Lin wrote:
> I'm writing a completion where, in some cases, I'd like to use
> COMPREPLY=() to indicate that no more arguments to a command are
> expected, but in other cases, I'd like to offer the default Readline
> behavior for filename completions.
> So, if I have a directory 'foo', I'd like the shell to first complete
> with 'foo/' and then offer to complete files under 'foo'. But if I do
> something like COMPREPLY=($(compgen -f -- "$cur")), then I simply get
> a completion of 'foo' (with a space appended).
> I know I can pass "-o default" to get Readline's default filename
> completion when COMPREPLY is empty, but then that seems to preclude
> using COMPREPLY=() to deny completions.

The `compopt' builtin was intended to add this kind of dynamism to
programmable completion shell functions.  You can install a completion
without -o default and turn it on using compopt when the completion
function is executed.  It appears to be lightly used, so there are
probably some usability improvements to be made there.  For instance, I
think that options, once set using compopt, remain set and need to be
manually disabled.  I'm waiting for some more reports from people using
it before I decide how (or whether) to change it.


``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]