I'm trying to get fzf to use rg --files
as its command for searching, but can't seem to get it to use the $FZF_DEFAULT_COMMAND
environment variable, as described in the docs.
I use fish
as my shell, and in my config.fish
I have set FZF_DEFAULT_COMMAND
rg --files. If I
echo $FZF_DEFAULT_COMMANDin my shell, I get
rg --files`, so fish is definitely aware of it.
However, when I call fzf
it doesn't use this command (for example, it shows gitignored files, such as build outputs etc, but if I just call rg --files
, these aren't shown).
The man page for fzf
says: "On *nix systems, fzf runs the command with sh -c
, so make sure that it's POSIX-compliant". However, if I run sh -c "echo $FZF_DEFAULT_COMMAND
, I get rg --files
.
Clearly this env var isn't available in the right place, but I'm at a bit of a loss to know how to set it properly. Any help appreciated
FZF_DEFAULT_COMMAND
exported as an environment variable? You can tell by runningenv
and seeing if it's present in the output. You can export it via the-x
flag toset
, e.g.set -gx FZF_DEFAULT_COMMAND ...
sh -c "echo $FZF_DEFAULT_COMMAND"
, that interpolated the variable in Fish. You would needsh -c 'echo $FZF_DEFAULT_COMMAND'
orsh -c "echo \$FZF_DEFAULT_COMMAND"
to pass it tosh
properly. That was likely throwing you off a bit as well. Now that you have it exported, it will show with either version.