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

Re: autocomplete in program



On Mon, Jan 8, 2018 at 4:30 PM, Emanuel Berg <moasen@xxxxxxxx> wrote:
>
>> If I send an incomplete filename to
>> a function, and then do the [[ -f $file ]]
>> test to determine if it is a file, and if it
>> isn't, can I programmatically do the
>> equivalent of interactive TAB, and if this
>> yields and unambiguous filename, use
>> that instead?
>
> I got help on #zsh on irc.freenode.net:
>
>     matches=( ${file}*(N) )
>

You can also use approximate matching:

setopt extendedglob
matches=( (#a3)${file}(N) )

Here 3 means up to 3 characters in $file may be wrong or missing.



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