Zsh-autosuggestions: sources ~/.zshrc as well as type <space> then the shell would be broken

Created on 5 Nov 2016  Â·  7Comments  Â·  Source: zsh-users/zsh-autosuggestions

i like this plugins, it's fast and practicality.
i was using oh-my-zsh
add the zsh-autosuggestions to zsh plugins
i was source ~/.zshrc and then type everything + space and shell broken right away every time as same

this plugins
plugins=(zsh-autosuggestions zsh-syntax-highlighting git z rails)
config
bindkey '^ ' autosuggest-accept

duplicate

Most helpful comment

@clay-f I haven't actually tried the solution there, but I managed to work around it by only sourcing
zsh-syntax-highlighting when the profile is loaded at shell startup, and not when it is sourced again, like this (in my .zshrc):

if [[ $ZSH_EVAL_CONTEXT == 'file' ]]; then
    source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
fi

All 7 comments

I'm not sure if the exact nature of this problem is understandable from @clay-f's description, but the issue is simple:

If zsh-autosuggestions is enabled, then sourcing the .zshrc file once zsh is already running will cause zsh to crash when the next key is pressed.

I'm not sure why exactly this happens, since sourcing zsh-autosuggestions itself multiple times does not cause the problem.

Okay, playing with this a bit, and for me the issue seems to be a combination of zsh-autosuggestions and zsh-syntax-highlighting.

Specifically, the problem is triggered by sourcing zsh-syntax-highlighting a second time, but only if zsh-autosuggestions has already been sourced.

So I'm not sure which module actually has the bug…

Upon further research this seems to be a dupe of #126 so should probably be closed in favour of that thread.

See also https://github.com/zsh-users/zsh-syntax-highlighting/issues/286 where the maintainer of zsh-syntax-highlighting states that this bug should be fixed in zsh-autosuggestions and not in zsh-syntax-highlighting.

oh

@caesaroh,
thanks, #126 reference @danielshahaf

edit plugins/zsh-autosuggestions/src/start.zsh to

_zsh_autosuggest_start() {
        _zsh_autosuggest_check_deprecated_config
        _zsh_autosuggest_bind_widgets
+       add-zsh-hook -d precmd _zsh_autosuggest_start
 }
autoload -Uz add-zsh-hook

make
but not make sense,

although source ~/.zshrc shell not be broken, but the z-aut plug didn't work.

seem there is not clear point to fixed that issue ?

@clay-f I haven't actually tried the solution there, but I managed to work around it by only sourcing
zsh-syntax-highlighting when the profile is loaded at shell startup, and not when it is sourced again, like this (in my .zshrc):

if [[ $ZSH_EVAL_CONTEXT == 'file' ]]; then
    source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
fi

@caesar zsh-syntax-highlighting and zsh-autosuggestions same time sourcing ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mindyourlifeguide picture mindyourlifeguide  Â·  6Comments

dragonxlwang picture dragonxlwang  Â·  3Comments

srajasimman picture srajasimman  Â·  5Comments

NikKovIos picture NikKovIos  Â·  4Comments

mehedi-sharif picture mehedi-sharif  Â·  6Comments