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

Re: default to file completion



On Dec 23, 12:01am, Miek Gieben wrote:
}
} > >    ./scan -zone <TAB>
} > >
} > > And nothing gets completed. How can I tell zsh to fallback to filename
} > > completion at that point?
} > 
} > "scan" is a command that already has completion in zsh
} 
} Is there a way to disable the default completion for the
} command 'scan' if you start it with './' ?

You can intercept completion pretty early on by providing a compdef for
the special context "-first-".

-first-
     This is tried before any other completion function.  The function
     called may set the _compskip parameter to one of various values:
     all: no further completion is attempted; a string containing the
     substring patterns: no pattern completion functions will be
     called; a string containing default: the function for the
     `-default-' context will not be called, but functions defined for
     commands will [be]

Although it's not documented in the man pages, this can also be done by
redefining the function _first (which by default is a no-op).  Hence:

    _first() {
      if [[ CURRENT -gt 1 && "${words[1]}" = ./* ]];
      then
        _compskip=all
        _files
      fi
    }

There's a much more complicated example as a large comment in the _first
function that is supplied with the shell.



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