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

Re: rsync --progress stops completion

On 09/21/2014 07:20 PM, Bart Schaefer wrote:
> To permit zstyle customizations it might also be useful to set up the
> "compcontext" parameter and call _complete instead of "_normal -s".
> There aren't any good examples of this except Functions/Misc/nslookup.

So here's what I got so far:



typeset -a _complete_fallback_precmd


  if [[ $LASTWIDGET = *complete* || -n $_complete_fallback_precmd ]]
    if [[ -z $_complete_fallback_active ]]
      precmd_functions+=( _complete_fallback_cleanup )

    [[ $compstate[context] = command && $CURRENT -gt 2 ]] || return 1
    words=("$words[1]" "${(@)words[$CURRENT,-1]}")
    local curcontext="${curcontext%:*}:fallback"

_complete_fallback "$@"


First, I hook into "precmd_functions" to setup some cleanup actions. The
idea is that once fallback is active, it's immediately entered upon the
completion of another argument. I couldn't find a better way to perform
cleanup really.

This allows rsync --random something [tab] to immediately enter the
fallback if it was enabled at least once.

Then I just append "fallback" to curcontext, so that in theory if you
wanted to customize the fallback, you could match the style on

So then I tried to change the prompt so that I get an indicator that the
fallback is active. But changing PROMPT/RPROMPT inside the completer
doesn't redraw the prompt until the command is accepted. Is there a way
to force the prompt to be updated?

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