Zsh auto-suggestion stopped working

hello everyone,
after I changed my prompt the auto-suggestion feature is not working like before if I would type
nvim .z it suggested nvim .zshrc but now its is not suggesting any more.
this is my .zshrc :point_down:

# Use powerline
USE_POWERLINE="false"
# Source manjaro-zsh-configuration
if [[ -e /usr/share/zsh/manjaro-zsh-config ]]; then
  source /usr/share/zsh/manjaro-zsh-config
fi
# Use manjaro zsh prompt
#if [[ -e /usr/share/zsh/zsh-maia-prompt ]]; then
#  source /usr/share/zsh/zsh-maia-prompt
#fi
#PROMPT="%B%{$fg[cyan]%}%(4~|%-1~/.../%2~|%~)%u%b >%{$fg[cyan]%}>%B%(?.%{$fg[cyan]%}.%{$fg[red]%})>%{$reset_color%}%b "

#PROMPT
PS1="%B%{$fg[red]%}[%{$fg[yellow]%}%n%{$fg[green]%}@%{$fg[blue]%}%M %{$fg[magenta]%}%~%{$fg[red]%}]%{$reset_color%}$%b "

export EDITOR=nvim


#aliases
alias nv='nvim'

alias ls='ls --color=auto'
alias grep='grep --colour=auto'
alias egrep='egrep --colour=auto'
alias fgrep='fgrep --colour=auto'

# vi mode
bindkey -v
export KEYTIMEOUT=1

# Enable searching through history
#bindkey '^R' history-incremental-pattern-search-backward

# Edit line in vim buffer ctrl-v
autoload edit-command-line; zle -N edit-command-line
bindkey '^v' edit-command-line
# Enter vim buffer from normal mode
autoload -U edit-command-line && zle -N edit-command-line && bindkey -M vicmd "^v" edit-command-line

# Use vim keys in tab complete menu:
#bindkey -M menuselect 'h' vi-backward-char
#bindkey -M menuselect 'j' vi-down-line-or-history
#bindkey -M menuselect 'k' vi-up-line-or-history
#bindkey -M menuselect 'l' vi-forward-char
#bindkey -M menuselect 'left' vi-backward-char
#bindkey -M menuselect 'down' vi-down-line-or-history
#bindkey -M menuselect 'up' vi-up-line-or-history
#bindkey -M menuselect 'right' vi-forward-char

# Fix backspace bug when switching modes
bindkey "^?" backward-delete-char


# Change cursor shape for different vi modes.
function zle-keymap-select {
  if [[ ${KEYMAP} == vicmd ]] ||
     [[ $1 = 'block' ]]; then
    echo -ne '\e[1 q'
  elif [[ ${KEYMAP} == main ]] ||
       [[ ${KEYMAP} == viins ]] ||
       [[ ${KEYMAP} = '' ]] ||
       [[ $1 = 'beam' ]]; then
    echo -ne '\e[5 q'
  fi
}
zle -N zle-keymap-select
zle-line-init() {
    zle -K viins # initiate `vi insert` as keymap (can be removed if `bindkey -V` has been set elsewhere)
    echo -ne "\e[5 q"
}
zle -N zle-line-init
echo -ne '\e[5 q' # Use beam shape cursor on startup.
preexec() { echo -ne '\e[5 q' ;} # Use beam shape cursor for each new prompt.

It only works with commands previously run in that shell, if you reload the shell you clear the autosuggestions. Does it work after running the command?

Hello,

I think that you need autosuggestions plugin for that. Check if you have it in /usr/share/zsh/manjaro-zsh-config. I personally don’t use manjaro zsh config, so I wouldn’t know. I roll with my own (found everything on the internet and modified to my own liking :sweat_smile:).

This is just an idea.

no it didn’t suggest me the command I just ran.

It was working and suggesting me before I changed my prompt.

I can’t see anything wrong with your prompt.

Try this source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh ,
add it at the end of the .zshrc.

EDIT After adding restart the terminal.

silly me I looked up the zsh-config it was not sourcing the plugin.

I did this and it works now. :grinning_face_with_smiling_eyes:

Also, there is a plugin section in /usr/share/zsh/manjaro-zsh-config file; you can also add the

source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh

line there as a permanent solution, if needed. :slightly_smiling_face:

1 Like

okay thankYou for the suggestion :grinning_face_with_smiling_eyes:

source ~/.zshrc

Would this command do the same? :thinking:

Yes, it would.

If the package changes somehow you will lose the auto-suggestions again. The permanent solution is the ~/.zshrc . Only you can change that one.

1 Like

OK. My bad :sweat_smile:. Thanks for the clarification.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.