junegunn / fzf

:cherry_blossom: A command-line fuzzy finder
https://junegunn.github.io/fzf/
MIT License
63.72k stars 2.37k forks source link

`cd **$<Tab>` fails to show candidates list of environment variables if rewriting `_fzf_compgen_dir` [autocomplete] #2570

Open fjchen7 opened 3 years ago

fjchen7 commented 3 years ago

Info

Problem / Steps to reproduce

I rewrite _fzf_compgen_dir as following

_fzf_compgen_dir() {
    fd --color=always --type d --max-depth 2 --hidden --follow --exclude ".git" . "$1"
}

However cd **$<tab> always gives directory candidates with $ as query, while what I want is searching in environment variables list.

I try to filter $ out from _fzf_compgen_dir's input and modify it like this

_fzf_compgen_dir() {
    if [[ "$1" == "\$" ]]; then
        env | cut -d"=" -f1
    else 
        fd --color=always --type d --max-depth 2 --hidden --follow --exclude ".git" . "$1"
    fi
}

But it still doesn't work.

Very appreciate it if anyone can provider some insights.

Randalix commented 1 year ago

I'm trying to do something similar. Did you found a solution?