zsh-autosuggestions: The color of the automatic prompt is incorrect.

Describe the bug

After running the source .zshrc command, the color of the auto prompt is displayed incorrectly and is not grayed out.

To Reproduce

Steps to reproduce the behavior:

  1. Run source .zshrc command.
  2. Enter other commands to see tips

Expected behavior

The tips section should be gray.

Screenshots

  • Expected behavior Expected

  • Current behavior Current

demo

Desktop

  • OS + distribution: macOS 10.15.2 (19C57) && Darwin 19.2.0
  • Zsh version: 5.7.1
  • Plugin version: ae315ded4dba10685dbbafbfa2ff3c1aefeb490d

Additional context

Although running the exec zsh command will make it display properly, but this does not completely solve the problem.Every time I run source .zshrc, it reproduces the incorrect display.

`.zshrc` file content
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
  source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi

if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

# Export Set
export ZSH="$HOME/.oh-my-zsh"
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"

# Base Set
COMPLETION_WAITING_DOTS="true"
ENABLE_CORRECTION="true"
# ZSH_DISABLE_COMPFIX="true"
ZSH_THEME="powerlevel10k/powerlevel10k"

# Plugins Set
plugins=(
  autojump
  git
  zsh-autosuggestions
  zsh-completions
  zsh-syntax-highlighting
)

autoload -U compinit && compinit
# This loads nvm
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

# Source Set
source $ZSH/oh-my-zsh.sh
# source ~/.bash_profile
if [ -f ~/.bash_profile ]; then
    . ~/.bash_profile;
fi

[[ -s $(brew --prefix)/etc/profile.d/autojump.sh ]] && . $(brew --prefix)/etc/profile.d/autojump.sh

# Alias Set
alias ll='ls -alFh'
alias flushdns='sudo killall -HUP mDNSResponder'

# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh

Other issues

By the way, how can plug-ins like this installed through git be updated? The install.md only says how to install through git, but does not tell me how to update.

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Comments: 23 (8 by maintainers)

Most upvoted comments

Indeed. Shooting yourself in the foot can cause problems. One could be curious under which conditions this pointless and dangerous exercise is less or more painful. Investigating this isn’t productive use of anyone’s time though.

@romkatv

Did you notice the gif picture I sent above?

Yes.

You can obviously see that if powerlevel10k is not enabled, running source ~/.zshrc does not cause any side effects with the ‘zsh-autosuggestions’ plugin. Everything looks normal.

When you run source ~/.zshrc, pretty much anything can happen. Sometimes this “anything” is nothing. Or it can appear to be nothing. Maybe your shell is a bit broken. Maybe it’s a bit slower.

But if powerlevel10k is enabled, then running the source ~/.zshrc command will cause the ‘zsh-autosuggestions’ plugin to display incorrectly.

Anything can happen.

The color of the automatic prompt should have been gray.

No. Anything goes.

If powerlevel10k is not enabled, no matter how many times you run source ~/.zshrc, it will not cause problems with the display of the’ zsh-autosuggestions’ plugin.

OK.

So I said there was a conflict.

You are incorrect.

Here’s an analogy.

  • Problem: when I shoot myself in the foot, it hurts.
  • Solution: don’t.

If there was any reason for you to run source ~/.zshrc, then saying “don’t” wouldn’t be appropriate. There is no reason though, so just don’t. You’ll lose nothing if you stop running this command.

#516 worked for me. I use zsh-syntax-highlighting and zsh-autosuggestions at the same time. I had the same issue, except that it happened all the time irrespective of whether I used exec zsh or source ~/.zshrc, but it worked normally after I commented out the highlighting plugin. It turns out that the plugin have not been updated for quite a long time. The problem was gone after I updated zsh-syntax-highlighting.

Looks like a dup of https://github.com/zsh-users/zsh-autosuggestions/issues/516. Take a look there.

You can update plugins installed through git by running git pull (or any other git commands) in the cloned repo.