junegunn / fzf

:cherry_blossom: A command-line fuzzy finder
https://junegunn.github.io/fzf/
MIT License
65.47k stars 2.41k forks source link

fzf completion not work #1596

Closed MrZhang123 closed 5 years ago

MrZhang123 commented 5 years ago

Use fzf completion in zsh and bash, but it not work, enter vim **<Tab> or cd **<Tab> , they all show this folders all files like this :

vim README.md tmux vim vscode zsh

fzf config in zsh:

export FZF_DEFAULT_COMMAND="rg --files --hidden -g'!.git'"
export FZF_DEFAULT_OPTS="--height 60% --layout=reverse"

How to set to use completion ?

junegunn commented 5 years ago

Please follow the instruction in https://github.com/junegunn/fzf#installation. Install script will update your shell configuration file to load scripts in https://github.com/junegunn/fzf/tree/master/shell

eggbean commented 3 years ago

I have been using fzf for a long time, but I forgot about ** a long time ago. I have just realised that it is not working and when I reran the installer script it didn't change anything regarding this. How can I test why it is not working with my dotfiles?

JREAM commented 2 years ago

I had this problem also, the way it worked for me on Ubuntu 22 was to install by git cloning instead of using apt and running the installed from the cloned folder by cd into it rather then running ~/.fzf/install

git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install
cd ~/.fzf
./install 
# Yes to all the options 

That appends a source of ~/.fzf.bash in your .bashrc, and that sourced file will source the auto-completions from ~/.fzf/shell/completions.bash.

eggbean commented 2 years ago

@JREAM What I currently do to install/update fzf (on Linux x86_64) is this:

#!/bin/bash
nameregex='^fzf-\d[\d.]+?\d?-linux_amd64\.tar\.gz$'
wget -q "$(curl -s https://api.github.com/repos/junegunn/fzf/releases/latest | jq -r '.assets[] | select(.name|test($name)).browser_download_url' --arg name "${nameregex}")"
tar --wildcards -C /usr/local/bin -xf fzf-*-linux_amd64.tar.gz
rm fzf-*-linux_amd64.tar.gz
wget https://github.com/junegunn/fzf/raw/master/man/man1/fzf.1 -O /usr/local/share/man/man1/fzf.1
gzip -f /usr/local/share/man/man1/fzf.1
wget https://github.com/junegunn/fzf/raw/master/man/man1/fzf-tmux.1 -O /usr/local/share/man/man1/fzf-tmux.1
gzip -f /usr/local/share/man/man1/fzf-tmux.1
wget https://github.com/junegunn/fzf/raw/master/bin/fzf-tmux -O /usr/local/bin/fzf-tmux
chmod +x /usr/local/bin/fzf-tmux
wget https://github.com/junegunn/fzf/raw/master/shell/completion.bash -O /etc/bash_completion.d/fzf-completions.bash
wget https://github.com/junegunn/fzf/raw/master/shell/key-bindings.bash -O /etc/bash_completion.d/fzf-keybindings.bash    

This updates the fzf binary, the fzf-tmux script, man files, bash completion file and keybindings files and it avoids needing its own directory in your $HOME. A lot neater I think.

eggbean commented 2 years ago

Just something I learnt quite recently which is sort of relevant to this conversation, so I'll mention that bash completion files that are placed anywhere other than /etc/bash_completion.d/ are lazy-loaded, so they only load when called upon explicitly, so files placed in there need to be named the same as the command (eg. fzf or fzf.bash).

But as we have two files, and they do not seem to work when concatenated, they either need to be placed in /etc/bash_completion.d/ or (I think) ~/.local/bash_completion, or specifically sourced from .bashrc.

otakutyrant commented 1 year ago

I installed fzf using the official package manager in Arch Linux. However in order to get fzf completion work I have to source /usr/share/fzf/completion.zsh in my .zshrc.

devilelephant commented 5 months ago

Not sure if this is related to your issue but I had the same problem until I figured out that I was setting my terminal to vi mode:

 set -o vi

After my fzf config, which killed the '**' completions (keybindings still worked).

Solution: Just moved the vi mode setting above the fzf settings.

lobut commented 3 months ago

I'm not good at any of this but I had an issue where this was conflicting with the zsh-vi-mode plugin.

I needed to add the ZVM_INIT_MODE:

ZVM_INIT_MODE=sourcing 
source $(brew --prefix)/opt/zsh-vi-mode/share/zsh-vi-mode/zsh-vi-mode.plugin.zsh

without it ** would always list all the directories, I also moved the fzf config afterwards as well. I hope this helps anyone else as well