zsh-users
 help / color / mirror / code / Atom feed
* autocomplete in program
@ 2018-01-08 23:56 Emanuel Berg
  2018-01-09  0:30 ` Emanuel Berg
  0 siblings, 1 reply; 3+ messages in thread
From: Emanuel Berg @ 2018-01-08 23:56 UTC (permalink / raw)
  To: zsh-users

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?

-- 
underground experts united
http://user.it.uu.se/~embe8573


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: autocomplete in program
  2018-01-08 23:56 autocomplete in program Emanuel Berg
@ 2018-01-09  0:30 ` Emanuel Berg
  2018-01-09  0:40   ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Emanuel Berg @ 2018-01-09  0:30 UTC (permalink / raw)
  To: zsh-users

YT 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) )

-- 
underground experts united
http://user.it.uu.se/~embe8573


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: autocomplete in program
  2018-01-09  0:30 ` Emanuel Berg
@ 2018-01-09  0:40   ` Bart Schaefer
  0 siblings, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 2018-01-09  0:40 UTC (permalink / raw)
  To: Zsh Users

On Mon, Jan 8, 2018 at 4:30 PM, Emanuel Berg <moasen@zoho.com> 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.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-01-09  0:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-08 23:56 autocomplete in program Emanuel Berg
2018-01-09  0:30 ` Emanuel Berg
2018-01-09  0:40   ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).