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

Re: default to file completion



On Sun, Dec 18, 2011 at 11:11:32AM +0100, Miek Gieben wrote:

> I've tried searching a bit, but I can not seem to find this specific
> problem. I've enablef completion in zsh and now I'm running a program
> of my own making (hence unknown to zsh): 'scan'
> 
> If I use tab completion the following happens:
> 
>     ./scan -zone <TAB>
> 
> And nothing gets completed. How can I tell zsh to fallback to filename
> completion at that point?

Here's an alternative to a case by case disabling of zsh completion, or
renaming commands.

    1. To plain old fall back on filename completion:

	    zstyle ':completion:*' completer _expand _complete _files \
		_correct _approximate

       The important thing above is the "_files" entry. This means if
       expansion or completion fails, it will try filename completion.
       (If that fails too, it will try correction or approximation.)

    2. Define a widgit that just completes files, and bind it to
       something (e.g. <C-X>f, in the example below).

	    zle -C complete-file menu-expand-or-complete _generic
	    zstyle ':completion:complete-file:*' completer _files
	    bindkey -M viins '^Xf'      complete-file
    
       (Change -M viins to -M emacs if you don't use VI keys)

       This allows you to complete files anywhere, on any command, at
       any time, by pressing <C-X>f (i.e. Control X, followed by f).

GI

-- 
100 THINGS I'D DO IF I EVER BECAME AN EVIL OVERLORD
34. I will not turn into a snake. It never helps.

Attachment: signature.asc
Description: Digital signature



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