Search code examples
zshoh-my-zsh

_expand_alias widget seems to be missing from ZLE


I'm trying to auto-expand aliases as I type in zsh using the globalias plugin from oh-my-zsh. It was working when I first installed the plugin, but now it has broken. I think it broke after I rearranged the lines in my ~/.zshrc but I'm not sure.

I've tried to simplify the problem by removing everything except the following lines form my ~/.zshrc (I got this from a reddit thread but it also looks v similar to the function in the globalias plugin):

function expand-alias() {
    zle _expand_alias
    zle self-insert
}
zle -N expand-alias
bindkey -M main ' ' expand-alias

When I source this file and type a space in my prompt, I see

No such widget `_expand_alias'

I've tried googling and it seems like _expand_alias should be a built-in ZLE function, but when I look for it with zle -la | grep _expand_alias it's not there.

I'm not sure what to try next? I can't find a way to reset zsh or the built-in ZLE commands.


Solution

  • I solved it by adding the line autoload -Uz compinit && compinit near the start of my ~/.zshrc.

    Hope this helps someone!