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

Re: _gnu_generic for aliases



On May 19, 10:50am, Paul Seyfert wrote:
}
} I crosschecked that also
} 
}        compdef _gnu_generic fancyalias
} 
} does not result in any suggestions. My understanding is that the
} _gnu_generic function does not know about the fancyalias / I cannot use
} the fancyalias inside the _gnu_generic function.
} 
} Is there a way to make _gnu_generic work for aliases?

Have you tried "setopt complete_aliases" ?

Unfortunately it's not easily possible to have it both ways, that is, to
treat an alias as something you can "compdef" and ALSO have the alias be
expanded to use the completion for the command it eventually becomes.

This might work a lot of the time:

setopt complete_aliases
_expand_alias_and_complete() {
  if [[ -o complete_aliases && -n $aliases[$words[1]] ]]; then
    words[1]=( $aliases[$words[1]] )
    _complete
  else
    return 1
  fi
}
zstyle ':completion:*' completer _complete __expand_alias_and_complete

Needs tweaking based on the rest of your current "completer" style, but
hopefully you get the idea.



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