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

Re: rsync --progress stops completion



On 09/21/2014 10:27 PM, Yuri D'Elia wrote:
> Any obvious problems you can spot?

And as I say it, an obvious tweak: only enable the fallback if we're attempting to complete a new word. This prevents the fallback to be triggered if we're attempting to complete a bad argument/file name.

#autoload
local -a _complete_fallback_precmd

_complete_fallback_cleanup()
{
  precmd_functions=_complete_fallback_precmd
  _complete_fallback_precmd=()
}

_complete_fallback()
{
  if [[ -n $_complete_fallback_precmd || ( $LASTWIDGET = *complete* && -z $words[$CURRENT] ) ]]
  then
    if [[ -z $_complete_fallback_precmd ]]
    then
      _complete_fallback_precmd=precmd_functions
      precmd_functions+=( _complete_fallback_cleanup )
      compadd -x "fallback: enabled"
      return 0
    fi

    [[ $compstate[context] = command && $CURRENT -gt 2 ]] || return 1
    words=("$words[1]" "${(@)words[$CURRENT,-1]}")
    CURRENT=2
    _compskip=default
    _complete
  fi
}

_complete_fallback "$@"




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