marlonrichert / zsh-autocomplete

🤖 Real-time type-ahead completion for Zsh. Asynchronous find-as-you-type autocompletion.
MIT License
5.34k stars 148 forks source link

Autocomplete not selecting some commands. #436

Closed RafaelMoreira1180778 closed 2 years ago

RafaelMoreira1180778 commented 2 years ago

Environment

$ print $VENDOR $OSTYPE $SHELL $ZSH_ARGZERO $ZSH_PATCHLEVEL
pc linux-gnu /usr/bin/zsh zsh zsh-5.8.1-0-g1a490c7

$ print -l $_autocomplete__funcfiletrace
<empty>

$ git -C ~zsh-autocomplete log --oneline -n1
7ab87cb (grafted, HEAD -> main) Remove the Zsh version checks

Steps to reproduce

cd $(mktemp -d)
git clone --depth 1 -- https://github.com/marlonrichert/zsh-autocomplete.git
> .zshrc <<EOF
PS1='%# ' PS2= RPS2='%^'; setopt transientrprompt interactivecomments
source ~/zsh-autocomplete/zsh-autocomplete.plugin.zsh
EOF
env -i HOME=$PWD PATH=$PATH TERM=$TERM ${TERMINFO:+TERMINFO=$TERMINFO} zsh -d

I cannot reproduce the error in the above environment, but here is the Record that shows the error:

asciicast

Here is my ~/.zshrc file:

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

export ZSH="$HOME/.oh-my-zsh"

ZSH_THEME="powerlevel10k/powerlevel10k"
plugins=(
  git
  sudo
  docker
  docker-compose
)

source $ZSH/oh-my-zsh.sh

# P10K
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh

# NVM
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"

# Autocompletions

# ZSH AutoComplete
source ~/.zsh-plugins/zsh-autocomplete/zsh-autocomplete.plugin.zsh

# SSH
h=()
if [[ -r ~/.ssh/config ]]; then
  h=($h ${${${(@M)${(f)"$(cat ~/.ssh/config)"}:#Host *}#Host }:#*[*?]*})
fi
# if [[ -r ~/.ssh/known_hosts ]]; then
#   h=($h ${${${(f)"$(cat ~/.ssh/known_hosts{,2} || true)"}%%\ *}%%,*}) 2>/dev/null
# fi
if [[ $#h -gt 0 ]]; then
  zstyle ':completion:*:ssh:*' hosts $h
  zstyle ':completion:*:slogin:*' hosts $h
fi

setopt no_flow_control
function fzf-ssh () {
  local selected_host=$(grep "Host " ~/.ssh/config | grep -v '*' | cut -b 6- | fzf --query "$LBUFFER" --prompt="SSH Remote > ")

  if [ -n "$selected_host" ]; then
    BUFFER="ssh ${selected_host}"
    zle accept-line
  fi
  zle reset-prompt
}

zle -N fzf-ssh
bindkey '^s' fzf-ssh

# AWS
export PATH=/usr/local/bin/aws_completer:$PATH
complete -C '/usr/local/bin/aws_completer' aws

# Manual
fpath=(~/.zsh-completions $fpath)
autoload -Uz compinit
compinit -u

# ALIASES

# K8S
alias k="/usr/bin/kubectl"
alias kc="/usr/bin/kubectx"
alias kn="/usr/bin/kubens"
alias kl="/usr/bin/kube-linter"

alias ka="/usr/bin/kubectl get all --output=wide"

# DOCKER
alias d="/usr/bin/docker"
alias dc="/usr/bin/docker-compose"

# COMPOSER
alias composer72="/usr/bin/php72 /usr/bin/composer"
alias composer73="/usr/bin/php73 /usr/bin/composer"
marlonrichert commented 2 years ago

It looks like you have something installed that redraws your command line while you are using the menu selection. Please comment out lines from .zshrc until you find what is conflicting with Zsh Autocomplete.

marlonrichert commented 2 years ago

Closing this, since I haven't heard back from @RafaelMoreira1180778.