Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autosuggestion not working for oh-my-zsh #416

Closed
b33f00d opened this issue Apr 9, 2019 · 50 comments
Closed

autosuggestion not working for oh-my-zsh #416

b33f00d opened this issue Apr 9, 2019 · 50 comments
Labels

Comments

@b33f00d
Copy link

b33f00d commented Apr 9, 2019

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?

@ericfreese
Copy link
Member

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

@b33f00d
Copy link
Author

b33f00d commented Apr 9, 2019

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

@ericfreese
Copy link
Member

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.

@b33f00d
Copy link
Author

b33f00d commented Apr 9, 2019

That seemed to work. Thanks

@b33f00d b33f00d closed this as completed Apr 9, 2019
@AshGrowem
Copy link

AshGrowem commented Apr 25, 2019

⚠️ 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 😅

@DeMol-EE
Copy link
Contributor

⚠️ 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?

@ericfreese
Copy link
Member

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

Good idea! Please feel free to write something up and send a PR.

ericfreese added a commit that referenced this issue Jun 22, 2019
@huwllewellyn
Copy link

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

@ghost
Copy link

ghost commented Feb 4, 2020

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

@keidarcy
Copy link

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

@bayronq
Copy link

bayronq commented Mar 1, 2020

thanks.

@hongshaoyang
Copy link

⚠️ 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!

@dipam7
Copy link

dipam7 commented Apr 18, 2020

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?

@veksha
Copy link

veksha commented Oct 30, 2020

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)

@ericfreese
Copy link
Member

@dipam7 it looks like you’re using bash. This is a plug-in for zsh so it won’t work in bash. Install and use zsh to use this plugin. It looks like there’s a good write up on installing zsh here https://github.com/ohmyzsh/ohmyzsh/wiki/Installing-ZSH

@igortuag
Copy link

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

@habibulr
Copy link

habibulr commented Dec 5, 2020

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

@ngtankhoa
Copy link

@veksha thank you so much! this works for me as well. I think this should be considered the accepted answer.

@eeerpjw
Copy link

eeerpjw commented Feb 5, 2021

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.

@rodrigoalmeidagit
Copy link

rodrigoalmeidagit commented Feb 18, 2021

I am currently using the theme below, which is the same as the initial OMZ standard, with only a few color changes.

# @host ➜ currentdir rvm:(rubyversion@gemset) git:(branchname)

# Get the current ruby version in use with RVM:
if [ -e ~/.rvm/bin/rvm-prompt ]; then
    RUBY_PROMPT_="%{$fg_bold[blue]%}rvm:(%{$fg[green]%}\$(~/.rvm/bin/rvm-prompt s i v g)%{$fg_bold[blue]%})%{$reset_color%} "
else
  if which rbenv &> /dev/null; then
    RUBY_PROMPT_="%{$fg_bold[blue]%}rbenv:(%{$fg[green]%}\$(rbenv version | sed -e 's/ (set.*$//')%{$fg_bold[blue]%})%{$reset_color%} "
  fi
fi

# Get the host name (first 4 chars)
HOST_PROMPT_="%{$fg_bold[green]%}@rodrigo-linux ➜ %{$fg_bold[cyan]%}%c "
GIT_PROMPT="%{$fg_bold[blue]%}\$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}"
PROMPT="$HOST_PROMPT_$RUBY_PROMPT_$GIT_PROMPT"

ZSH_THEME_GIT_PROMPT_PREFIX="git:( %{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]% %{$fg[yellow]%} ✗ %{$fg[blue]%)"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]% %{$fg[yellow]%} ✔ %{$fg[blue]%)"

It turns out that if I change the theme in the ~ / .zshrc file, to the Dracula theme, the auto suggestion stops working.

Can someone help me?
Thanks

@titaneric
Copy link

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?

Perhaps a little late. You are running zsh command in bash, you may set your default shell to zsh by sudo chsh -s $(which zsh) $USER.

@jonathanmdr
Copy link

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

@harmandeep-singh
Copy link

Folk like me generally did mistake pasting the end of file : follow the suggestion of @veksha

@jaydreyer
Copy link

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...

@locdhthtb
Copy link

locdhthtb commented Oct 26, 2021

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

@acgq
Copy link

acgq commented Nov 8, 2021

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

@patricksousamacedo
Copy link

patricksousamacedo commented Nov 20, 2021

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

@itzzmesid
Copy link

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

Worked

@faustaleonardo
Copy link

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)

A lifesaver. Thank you 👍

@blackboldxdevmedia
Copy link

⚠️ 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 😅

Awesome. Thanks!

@JackWP1
Copy link

JackWP1 commented May 11, 2022

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

@davidc360
Copy link

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

This worked for me

@jd-apprentice
Copy link

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

This solved the issue for me thanks!

@prawee
Copy link

prawee commented Sep 23, 2022

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.

@sani-sidqam
Copy link

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

this worked for me, thanks

@jonathanmdr
Copy link

I run $ git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions and It's worked for me.

@entwwwicklung
Copy link

entwwwicklung commented Nov 11, 2022

hmm for me the issue was that instead of having plugins listed like this in ~/.zshrc file
plugins=
(
git
zsh-autosuggestions
zsh-syntax-highlighting
)
had to change it to one line
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)

probably some spacing issue happened

@ArnaudRm
Copy link

ArnaudRm commented Dec 1, 2022

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.

@chiboycalix
Copy link

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

This fixed it for me as well..Thank you so much

@tsids
Copy link

tsids commented Apr 28, 2023

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 😂

@clauBv23
Copy link

⚠️ 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 😅

Oh, damn! 😮‍💨

@DebOM
Copy link

DebOM commented Jun 23, 2023

add source $ZSH/oh-my-zsh.sh to your ~/.zshrc. It started to work for me once added, even though I had the plugin set correctly

@dominikabieder
Copy link

I'm getting 'zsh-autosuggestions' not found and 'zsh-syntax-highlighting' not found even though they are working.

I can only download the zip, I put it in .zsh folder, then added the plugins and at the end source $ZSH/oh-my-zsh.sh - without it it wouldn't show the branch name.

What can I improve? I can't git clone, the antigen also didn't work despite installing it with brew.

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

source ~/.zsh/zsh-autosuggestions-master/zsh-autosuggestions.zsh
source ~/.zsh/zsh-syntax-highlighting-master/zsh-syntax-highlighting.zsh

source $ZSH/oh-my-zsh.sh

@gnsalok
Copy link

gnsalok commented Aug 22, 2023

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.

@manjushsh
Copy link

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)

Thank you. It worked!

@DavydovDenys
Copy link

All you need is to have only one line plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
In my case, I had 2 lines
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
plugins=(git ssh)
I just added git ssh to plugins=(git ssh zsh-autosuggestions zsh-syntax-highlighting) and remove the last line
plugins=(git ssh) and this worked for me.

@hoangneeee
Copy link

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)

thank you, it helps me

@sunwhw
Copy link

sunwhw commented Mar 30, 2024

  1. vim ~/.zshrc
  2. only add "source ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions", no "plugins"!
  3. source ~.zshrc
    it works for me!

@FahimFBA
Copy link

I followed the issue on macOS Sonoma like below:

  1. Ran this: git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions to clone and save them in the zsh's plugin's directory.
  2. Opened the config using open ~/.zshrc
  3. Changed plugins=(git) to plugins=(git zsh-autosuggestions)
  4. Reloaded the config using source ~/.zshrc

It worked flawlessly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests