Aloxaf / fzf-tab

Replace zsh's default completion selection menu with fzf!
MIT License
3.37k stars 97 forks source link

[Q]Why `rg --`no matches found, while other commands can, such as `git --` #474

Closed KuringM closed 1 month ago

KuringM commented 1 month ago
rg --<tab>
-- no matches found --

截屏2024-09-28 04 49 35

git --<tab>
--bare --use...
...

截屏2024-09-28 04 51 10

mini .zshrc

ZIM_CONFIG_FILE=~/.config/zsh/cli/zimrc
ZIM_HOME=~/.config/zim
if [[ ! -e ${ZIM_HOME}/zimfw.zsh ]]; then
  curl -fsSL --create-dirs -o ${ZIM_HOME}/zimfw.zsh \
      https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh
fi
if [[ ! ${ZIM_HOME}/init.zsh -nt ${ZIM_CONFIG_FILE:-${ZDOTDIR:-${HOME}}/.zimrc} ]]; then
  source ${ZIM_HOME}/zimfw.zsh init -q
fi
ZSH_COMPDUMP="$ZSH_CACHE/zcompdump"
zstyle ':zim:completion' dumpfile $ZSH_COMPDUMP
zstyle ':completion::complete:*' $ZSH_CACHE/zcompcache
source ${ZIM_HOME}/init.zsh
source ${ZIM_HOME}/modules/fast-syntax-highlighting/F-Sy-H.plugin.zsh
zstyle ':fzf-tab:complete:_zlua:*' query-string input
zstyle ':fzf-tab:*' fzf-command ftb-tmux-popup
zstyle ':fzf-tab:*' fzf-bindings 'ctrl-e:down' 'ctrl-u:up' 'ctrl-l:clear-query'
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'eza -1 --color=always $realpath' # remember to use single quote here!!!
zstyle ':fzf-tab:*' query-string prefix input first
petricavalry commented 1 month ago

Add following content to .zshrc.

autoload -Uz compinit bashcompinit
compinit
bashcompinit

Completions should be correctly installed by your package manager. If not, run as root:

mkdir /usr/local/share/zsh/site-functions
rg --generate=complete-zsh >/usr/local/share/zsh/site-functions/_rg
Aloxaf commented 1 month ago

git's completion file is shipped with zsh, while rg's is not.

You should install it manually, especially when you install rg by cargo.

KuringM commented 1 month ago

Thank you for solving my problem 👍