m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-17 15:53:39 -05:00

There are too many problems with how this solution works; fzf just really needs a "sort by path depth" option internally instead of trying to fake it this way

Patrick McFarland
2022-06-15 09:46:29 -07:00
parent e4412d3dd0
commit 109ecbcac6

@@ -76,39 +76,3 @@ complete -o bashdefault -o default -F _fzf_complete_ssh_notrigger ssh
complete -o bashdefault -o default -F _fzf_complete_ssh_notrigger mosh
complete -o bashdefault -o default -F _fzf_complete_ssh_notrigger ss
```
### Path depth and hidden sorted _fzf_compgen_path/dir (feat. `fd` and `rg`)
Based on the example in the [README](https://github.com/junegunn/fzf#settings) for `fd` integration, this sorts from least to greatest path depth and then sorts hidden files after regular ones. This puts the most likely files you're going to access further up in the list and gets them into `fzf` faster.
```bash
_fzf_compgen_path() {
local output
local -i depth=1
while
output=$(fd -H -L -E ".git" --exact-depth "$depth" . "$1")
rg -v "^\.|/\." <<<"$output"
rg "^\.|/\." <<<"$output"
depth+=1
[ "$output" ]
do true; done
}
_fzf_compgen_dir() {
local output
local -i depth=1
while
output=$(fd -H -L -E ".git" --exact-depth "$depth" -t d . "$1")
rg -v "^\.|/\." <<<"$output"
rg "^\.|/\." <<<"$output"
depth+=1
[ "$output" ]
do true; done
}
```