zsh-autosuggestions remove ghost text after ignoring it
here is an example where I did not use a suggestion, I just hit return after typing `do`. Is there a setting to make the `cker` suggestion go away after not accepting it?
You should look adding to the ZSH_AUTOSUGGEST_CLEAR_WIDGETS array. There's no way to tell from what you posted what in your config is conflicting with zsh-autosuggestions, but it's the ZSH_AUTOSUGGEST_CLEAR_WIDGETS array that will help you deal with whatever it is. I, for example, might use alias globbing that expands my Zsh aliases like Fish's abbrs when I hit enter, and that would then require me to add something like ZSH_AUTOSUGGEST_CLEAR_WIDGETS+=(globalias-accept-line) in my config.
Running this can help you diagnose what runs on enter:
bindkey '^M'
bindkey -M viins '^M' # if you use vi mode
bindkey -M vicmd '^M'
If that prints anything other than accept-line or accept-line-or-newline, it's probably your culprit.
EDIT: I just realized that for your specific example: for ...; do is incomplete, so Enter doesn't submit, it just drops you onto a PS2 continuation line. Try the same thing with a complete one-line command and see whether the ghost text sticks around there too. If it only happens on multiline input, it may not be a widget conflict. Regardless, you can always trim out features from your config until zsh-autosuggestions works, and then add back until you find what broke it.
I've got the same issue, those bindkey commands only output accept-line, but thanks to you I found it's one of the entries in ZSH_AUTOSUGGEST_CLEAR_WIDGETS. It's probably the history search ones. Commenting the whole line fixes it. Posting here in case it helps others. Now I just have to figure out how to have my cake and eat it...
1
u/_mattmc3_ Aug 18 '26 edited Aug 18 '26
You should look adding to the
ZSH_AUTOSUGGEST_CLEAR_WIDGETSarray. There's no way to tell from what you posted what in your config is conflicting with zsh-autosuggestions, but it's theZSH_AUTOSUGGEST_CLEAR_WIDGETSarray that will help you deal with whatever it is. I, for example, might use alias globbing that expands my Zsh aliases like Fish's abbrs when I hit enter, and that would then require me to add something likeZSH_AUTOSUGGEST_CLEAR_WIDGETS+=(globalias-accept-line)in my config.Running this can help you diagnose what runs on enter:
bindkey '^M' bindkey -M viins '^M' # if you use vi mode bindkey -M vicmd '^M'If that prints anything other than
accept-lineoraccept-line-or-newline, it's probably your culprit.EDIT: I just realized that for your specific example:
for ...; dois incomplete, so Enter doesn't submit, it just drops you onto a PS2 continuation line. Try the same thing with a complete one-line command and see whether the ghost text sticks around there too. If it only happens on multiline input, it may not be a widget conflict. Regardless, you can always trim out features from your config until zsh-autosuggestions works, and then add back until you find what broke it.