答案1
将其添加到您的~/.zshrc
文件中:
autoload -Uz compinit
compinit
# The code below should come _after_ initializing the completion system.
# Autoload the `galiases` table.
zmodload -Fa zsh/parameter p:galiases
# Whenever a completion is attempted, first run `_galiases`.
compdef _galiases -first-
_galiases() {
# Add the completions to the `aliases` group.
local expl
_description aliases expl 'alias'
# Add the keys from `galiases` as the actual completions.
compadd "$expl[@]" -Q -k galiases
}
(请注意,您不能将多个完成函数定义为-first-
。如果您有其他应首先调用的完成函数,那么您应该定义一个调用所有这些函数的伞函数。)
文档: