I'm trying to make fzfs autocompletion invoked on cat **<TAB> return only files (directories does not make sense for cat). According to docs it's the matter of defining _fzf_complete_cat(), so my first try was
_fzf_complete_cat() {
_fzf_complete -- "$@" < <(
fd --type f --hidden --follow --no-ignore --exclude .git
)
}
however, there's a major flaw: this completion does not take into account the path's part before **, e.g. if I am in ~/subdir and type cat ~/another/**<TAB> it will not recurse from there, but rather from ~/subdir.
I understand the trick is around these lines from fzf/shell/completion.zsh, namely, the way _fzf_[path|dir]_completion() handles it. So I tried smth like that (essentially, repeating the logic of the completion.zsh):
_custom_fzf_compgen_path() {
fd --hidden --follow --no-ignore --exclude ".git" . "$1"
}
_custom_fzf_path_completion() {
__fzf_generic_path_completion "$1" "$2" _fzf_compgen_path \
"-m" "" " "
}
_fzf_complete_cat() {
_custom_fzf_path_completion "$prefix" "$1"
}
and it almost works, messing up in the very end with zle reset-prompt from here.
TL;DR: I need **<TAB> for cat command work similarly to _fzf_[path|dir]_completion() but return only files.
Appreciate any ideas! Thanks!