Skip to content
Myr

Update README: Examples using fd

Before adoption: this commit came in with the history the project adopted, so no landing records it.

- https://github.com/sharkdp/fd - https://mike.place/2017/fzf-fd/ /cc @williamsmj

authored by Junegunn Choi · committed by Junegunn Choi · parent fe7b91d · Browse files · 1 file+20 added−23 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+20 added−23 removed

  • other:+20 added−23 removed

1 file+20 added−23 removed

modified:README.md+20 added-23 removed
229 unmodified lines
230#### Environment variables231232- `FZF_DEFAULT_COMMAND`233 - Default command to use when input is tty234 - e.g. `export FZF_DEFAULT_COMMAND='rg --files'`234 - e.g. `export FZF_DEFAULT_COMMAND='fd --type f'`235- `FZF_DEFAULT_OPTS`236 - Default options237 - e.g. `export FZF_DEFAULT_OPTS="--reverse --inline-info"`238
129 unmodified lines
368369# Options to fzf command370export FZF_COMPLETION_OPTS='+c -x'371372# Use rg (https://github.com/BurntSushi/ripgrep) instead of the default find372# Use fd (https://github.com/sharkdp/fd) instead of the default find373# command for listing path candidates.374# - The first argument to the function is the base path to start traversal374# - The first argument to the function ($1) is the base path to start traversal375# - See the source code (completion.{bash,zsh}) for the details.376# - rg only lists files, so we use with-dir script to augment the output376_fzf_compgen_path() {378 rg --files "$1" | with-dir "$1"377 fd --hidden --follow --exclude ".git" . "$1"378}379381# Use rg to generate the list for directory completion380# Use fd to generate the list for directory completion381_fzf_compgen_dir() {383 rg --files "$1" | only-dir "$1"382 fd --type d --hidden --follow --exclude ".git" . "$1"383}384```385387`only-dir` and `with-dir` scripts can be found [here][dir-scripts]. They are388written in Ruby, but you should be able to rewrite them in any language you389prefer.390391[dir-scripts]: https://gist.github.com/junegunn/8c3796a965f22e6a803fe53096ad7a75392386#### Supported commands387388On bash, fuzzy completion is enabled only for a predefined set of commands389(`complete | grep _fzf` to see the list). But you can enable it for other
92 unmodified lines
482483Tips484----485493#### Respecting `.gitignore`, `.hgignore`, and `svn:ignore`486#### Respecting `.gitignore`487488You can use [fd](https://github.com/sharkdp/fd),495[ripgrep](https://github.com/BurntSushi/ripgrep) or [the silver496searcher](https://github.com/ggreer/the_silver_searcher) can do the filtering:489[ripgrep](https://github.com/BurntSushi/ripgrep), or [the silver490searcher](https://github.com/ggreer/the_silver_searcher) instead of the491default find command to traverse the file system while respecting492`.gitignore`.493494```sh499# Feed the output of rg into fzf500rg --files | fzf495# Feed the output of fd into fzf496fd --type f | fzf497502# Setting rg as the default source for fzf503export FZF_DEFAULT_COMMAND='rg --files'498# Setting fd as the default source for fzf499export FZF_DEFAULT_COMMAND='fd --type f'500505# Now fzf (w/o pipe) will use rg instead of find501# Now fzf (w/o pipe) will use fd instead of find502fzf503504# To apply the command to CTRL-T as well505export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"506```507508If you want the command to follow symbolic links, and don't want it to exclude512If you don't want to exclude hidden files, use the following command:509hidden files, use the following command:510511```sh515export FZF_DEFAULT_COMMAND='rg --files --hidden --glob \!.git'512export FZF_DEFAULT_COMMAND='fd --type f --hidden --follow --exclude .git'513```514515#### `git ls-tree` for fast traversal516
52 unmodified lines