jethrokuan / fzf

Ef-🐟-ient fish keybindings for fzf
MIT License
863 stars 65 forks source link

Using fzf with fd has surprising behaviour #100

Closed skorokithakis closed 5 years ago

skorokithakis commented 5 years ago

I set the find command to fd, as in fzf's repo recommendation, and I am getting surprising behaviour when finding a file. Namely, when I am in ~/code/someproject/ and do vim /tmp/<Ctrl+f>, fzf starts up respecting the .gitignore file in the directory I am in, rather than the target directory, and displays no files in /tmp even though there are many.

I don't know if this is a problem with fzf or fzf-fish, so I figured I'd ask here first.

jethrokuan commented 5 years ago

I set the find command to fd, as in fzf's repo recommendation

The variable naming there is slightly different. Did you set the wrong variable? The way to do it with this plugin is:

set -U FZF_FIND_FILE_COMMAND "fd ..."
skorokithakis commented 5 years ago

Yes, this is my config.fish:

set FZF_FIND_FILE_COMMAND "fd --type f"

The problem is that fd gets launched in a way that makes it not work properly. I don't know what the exact command/directory/environment used to launch it is, so I couldn't test further, but if I do fd tmp /tmp/, I get a list of temp files.

Testing it now, if I do vim /tmp/<Ctrl-f> from the directory ~/code/someproject, the autocomplete box shows me files in ~/code/someproject rather than in /tmp/... Am I doing something wrong?

jethrokuan commented 5 years ago

I looked into it further, and you'd need to pass the variable $dir as a command, so something like:

set -U FZF_FIND_FILE_COMMAND "fd --type f . \$dir" works.

Unfortunately, I don't see a way to abstract these details away from users, as $dir may appear in different places for different find_file commands.

skorokithakis commented 5 years ago

Ah, you are right, that fixes it! I thought the directory was somehow appended.

I don't care so much about abstraction (I can figure it out on my own), as much as I care for an example in the README that will point me to the right direction. Do you want me to open a PR with your line in it?

jethrokuan commented 5 years ago

Sounds good! Thanks for reporting.

jethrokuan commented 5 years ago

Closed with #102