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

Added "Path depth and hidden sorted _fzf_compgen_path/dir"

Patrick McFarland
2022-05-13 18:55:32 -04:00
parent 722c744c4e
commit ead8a82776

@@ -75,4 +75,40 @@ _fzf_complete_ssh_notrigger() {
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
}
```