zsh-autosuggestions: autosuggestion not working for oh-my-zsh

So I thought my autosuggestion was working, I had ran this command source .oh-my-zsh/custom/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh and it was working fine, but right after I closed the terminal and opened up again the auto suggestion quit working. Any help?

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 15
  • Comments: 50 (5 by maintainers)

Commits related to this issue

Most upvoted comments

⚠️ Be sure iTerm’s “Background” and “ANSI Normal Black” are set to two distinctly different colors!

iTerm > Preferences > Profiles > Colors > ANSI Colors > Bright > Black iTerm > Preferences > Profiles > Colors > Basic Colors > Background

@yuungH4x0r I had the same problem. Turns out I had the autosuggestion color (ANSI Bright Black) set exactly the same as my iTerm background so they blended together perfectly and I just couldn’t see it 😅

I was missing the repo. To fix I ran: $ git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions

for me the problem was simply wrong order of commands in .zshrc

this line: plugins=(git z colored-man-pages zsh-syntax-highlighting zsh-autosuggestions)

was AFTER this line: source $ZSH/oh-my-zsh.sh

I just swapped them and after that all plugins were loaded correctly. (no need for manual sourcing of plugins)

running git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions solved this for me.

Ok I’m not sure why that wouldn’t be working then. Maybe there is a typo or something? You could always add the manual source line to your .zshrc.

None of the above suggestions worked for me. So I had to source directly to the file to get mine working. Maybe this might help someone else. Or maybe I’m missing a trick and there’s a better way of doing this…?

in my .zshrc file:

plugins=(zsh-autosuggestions)
source ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh

You need to configure OMZ to load zsh-autosuggestions on every start-up. Add zsh-autosuggestions to the list of OMZ plugins as described in step 2 of the OMZ installation instructions: https://github.com/zsh-users/zsh-autosuggestions/blob/master/INSTALL.md#oh-my-zsh

⚠️ Make sure iTerm’s “Background” and “ANSI Normal Black” are set to two distinctly different colors!

iTerm > Preferences > Profiles > Colors > ANSI Colors > Bright > Black iTerm > Preferences > Profiles > Colors > Basic Colors > Background

@yuungH4x0r I had the same problem. Turns out I had the autosuggestion color (ANSI Bright Black) set exactly the same as my iTerm background so they blended together perfectly and I just couldn’t see it 😅

Could this perhaps be added to the README somewhere, under troubleshooting?

That seemed to work. Thanks

for me the problem was simply wrong order of commands in .zshrc

this line: plugins=(git z colored-man-pages zsh-syntax-highlighting zsh-autosuggestions)

was AFTER this line: source $ZSH/oh-my-zsh.sh

I just swapped them and after that all plugins were loaded correctly. (no need for manual sourcing of plugins)

thanks you so much, it worked for me.

for me the problem was simply wrong order of commands in .zshrc

this line: plugins=(git z colored-man-pages zsh-syntax-highlighting zsh-autosuggestions)

was AFTER this line: source $ZSH/oh-my-zsh.sh

I just swapped them and after that all plugins were loaded correctly. (no need for manual sourcing of plugins)

Thanks, it worked for me as well

What worked for me was removing the spaces between the equal sign and the (git zsh-autosuggestions)

It was like this: plugins = (git zsh-autosuggestions)

I removed the spaces: plugins=(git zsh-autosuggestions)

And I put the source line below the plugins line:

plugins=(git zsh-autosuggestions)

source $ZSH/oh-my-zsh.sh

i using bash in git version 2.33.1.windows.1

anyone get error like this in terminal windows 10 , but “Git bash” is working

config .zshrc

* source $ZSH/oh-my-zsh.sh

* plugins=(zsh-syntax-highlighting zsh-autosuggestions)

* source ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions

typing space or any key press , get this : [?1h←

WindowsTerminal_2021-10--26__222549

I enconter this problem in windows too, disabling async mode (add unset ZSH_AUTOSUGGEST_USE_ASYNC in .zshrc) seem to be a workaround

I am trying to install zsh-autosuggestions. I followed the manual steps as well as homebrew steps. However, in both cases when I try to do source ~/.zshrc I get the following error:

-bash:  ! ${+ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE} : bad substitution
-bash:  ! ${+ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX} : bad substitution
-bash:  ! ${+ZSH_AUTOSUGGEST_STRATEGY} : bad substitution
-bash:  ! ${+ZSH_AUTOSUGGEST_CLEAR_WIDGETS} : bad substitution
-bash:  ! ${+ZSH_AUTOSUGGEST_ACCEPT_WIDGETS} : bad substitution
-bash:  ! ${+ZSH_AUTOSUGGEST_EXECUTE_WIDGETS} : bad substitution
-bash:  ! ${+ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS} : bad substitution
-bash:  ! ${+ZSH_AUTOSUGGEST_IGNORE_WIDGETS} : bad substitution
-bash:  ! ${+ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME} : bad substitution
-bash: /Users/dipamvasani/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh: line 95: syntax error near unexpected token `('
-bash: /Users/dipamvasani/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh: line 95: `		user:_zsh_autosuggest_(bound|orig)_*)'

Can someone tell me what’s wrong?

For people that encounters this issue trying to achieve that on Linux + terminator :

You just have to go to Preferences > Profile > Colors . In sub-menu Palette . Then, you must select Custom instead of Solarize Dark as a built-in themes. Finally, change the bottom left color to a lighter one.

Running this command solved it for me: $ git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions

for me the problem was simply wrong order of commands in .zshrc

this line: plugins=(git z colored-man-pages zsh-syntax-highlighting zsh-autosuggestions)

was AFTER this line: source $ZSH/oh-my-zsh.sh

I just swapped them and after that all plugins were loaded correctly. (no need for manual sourcing of plugins)

Thanks, it worked for me

⚠️ Make sure iTerm’s “Background” and “ANSI Normal Black” are set to two distinctly different colors!

To add on, under iTerm > Preferences > Profile > Colors, do not choose Solarized Dark as a Color Preset as “Background” and “ANSI Bright Black” are the same colour!

for me, messed up zsh-autosuggestions and zsh-completions. I know it’s stupid, but it cost me 5 minutes -_- hope you don’t 😉

Please validate below points to fix zsh-autosuggestions

  1. Make sure you do not define plugins=() twice in ~/.zshrc file. Sometimes while installing Oh My Zsh and Powerlevel10k, plugins=(git) automatically gets added, and you end up getting added it twice.
  2. In ~/.zshrc file, plugins=(git) line should come before source $ZSH/oh-my-zsh.sh.

If you mess up with step 2, you will end up debugging for hours.

For people that encounters this issue trying to achieve that on Linux + terminator :

You just have to go to Preferences > Profile > Colors . In sub-menu Palette . Then, you must select Custom instead of Solarize Dark as a built-in themes. Finally, change the bottom left color to a lighter one.

Thank you, this worked for me. I can’t believe the autosuggestions were working, but I couldn’t see them because of the background color of the terminal 😂

git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions

git clone https://github.com/zsh-users/zsh-syntax-highlighting ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting

source .zshrc

i solved.

Ha. In case any of the other suggestions don’t work for you, make sure you don’t somehow end up with two plugin sections in your .zshrc file like I did. I have no idea how that happened, but it’ll take the second one, and that wasn’t the one I was populating. Anyway…

Yea so I have that already in my .zshrc but still nothing and I restarted the terminal already.