unixorn / fzf-zsh-plugin

ZSH plugin to enable fzf searches of a lot more stuff - docker, tmux, homebrew and more.
Apache License 2.0
303 stars 27 forks source link

Problem in a system without fdfind and rg . #69

Closed andrewwutw closed 6 months ago

andrewwutw commented 1 year ago

I test on a Vagrant VM (ubuntu/focal64)

Make sure fdfind and rg are not installed :

which fdfind
fdfind not found
which rg
rg not found
which find
/usr/bin/find

Only find is installed. fdfind and rg are not.

Install the plugin :

git clone https://github.com/unixorn/fzf-zsh-plugin.git
source fzf-zsh-plugin/fzf-zsh-plugin.plugin.zsh

The plugin installs fzf executable file.

Run fzf , and a problem occurred :

Command failed: find . -type -f ( -path .git -o -path node_modules ) -pr..

Looks like fzf runs command specified by $FZF_DEFAULT_COMMAND, and it is an error.

$FZF_DEFAULT_COMMAND is a find command.

echo $FZF_DEFAULT_COMMAND

Outputs :

find . -type f ( -path .git -o -path node_modules ) -prune

But running this find command from zsh prompt :

find . -type f ( -path .git -o -path node_modules ) -prune

Failed, output is :

zsh: unknown file attribute:

But if fd program is installed :

sudo apt install fd-find

Reload the plugin :

unset FZF_DEFAULT_COMMAND
source fzf-zsh-plugin/fzf-zsh-plugin.plugin.zsh

Now running fzf is ok.

$FZF_DEFAULT_COMMAND is change to using fdfind :

echo $FZF_DEFAULT_COMMAND

Outputs :

fdfind --hidden --follow --exclude '.git' --exclude 'node_modules'

Installing rg also fixes the problem.

sudo apt install ripgrep
unset FZF_DEFAULT_COMMAND
source fzf-zsh-plugin/fzf-zsh-plugin.plugin.zsh
echo $FZF_DEFAULT_COMMAND

Outputs :

rg --files --hidden --glob "!.git/*"

I believe that running this command find . -type f ( -path .git -o -path node_modules ) -prune is the problem.

My zsh version :

zsh 5.8 (x86_64-ubuntu-linux-gnu)

andrewwutw commented 1 year ago

Maybe this issue is related to #50. The same $FZF_DEFAULT_COMMAND setting, and the same error message unknown file attribute.

ejalaa12 commented 1 year ago

I have the exact same issue, here is how I fixed it. The issue indeed comes from:

I believe that running this command find . -type f ( -path .git -o -path node_modules ) -prune is the problem.

This command does not work in zsh. If you run it you get what @andrewwutw said:

the same error message unknown file attribute

Fixing the command fixed the problem. So, to achieve the desired result, the default FZF_DEFAULT_COMMAND should be:

find . -type f -not \( -path "*/.git/*" -o -path "./node_modules/*" \)

This would search all files, excluding any file that is under a .git folder or a node_modules folder.

However, IMO, I belive this plugin should not change the default fzf command, as this is counter-intuitive and unexpected for new users. I used to use fzf and installing this plugin broke it because of this FZF_DEFAULT_COMMAND. Instead I would recommand setting the default fzf command to whatever fzf uses, i.e. no filters: find . -type f