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

Re: rsync --progress stops completion



On Sep 17, 10:08am, Yuri D'Elia wrote:
}
} > (Wow, gmane sent Yuri's messaeg through with no To/Cc headers.)
} 
} [I bcc'ed you]

(Obviously, but a message with no To header at all is theoretically
ill-formed, so I'm surprised gmane didn't mock up something.)

} It happens to me from time to time, though I'm usually not motivated
} enough to report it, that a command which is perfectly fine does not
} perform file completion anymore, which is probably *the* most important
} completer I care about.
} 
} Is there a way to somehow get this as a general behavior, or it's
} dependent on the specific command completion?

Sure, just add _files to the end of your completer zstyle, e.g.:

zstyle ':completion:*' completer _oldlist _expand _complete _files 

The completer style is tried in order until one of the named functions
returns zero; completion only fails if all of the functions fail.
With _files at the end, you'll always get default file completion when
all else fails.

You can get fancier; here's a (slightly crude) way to prompt for it:

zstyle ':completion:*' completer _oldlist _expand _complete _maybe_files
_maybe_files () {
    local q
    read -t 2 -q $'q?\nNo completions - try files? ' && _files || q=n
    zle -I
    [[ $q = y ]]
}

That could be extended e.g. to cache the names of commands for which the
answer was yes and skip the prompt for those next time.  (If you skip the
prompt, also skip the "zle -I".)

There are other tricks possible, e.g., to arrange that _files is called
only if you hit tab twice, but I'm going to let somebody else work that
solution out.



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