fzf icon indicating copy to clipboard operation
fzf copied to clipboard

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

Open fjchen7 opened this issue 4 years ago • 1 comments

  • [x] I have read through the manual page (man fzf)
  • [x] I have the latest version of fzf
  • [x] I have searched through the existing issues

Info

  • OS
    • [ ] Linux
    • [x] Mac OS X
    • [ ] Windows
    • [ ] Etc.
  • Shell
    • [ ] bash
    • [x] zsh
    • [ ] fish

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.

fjchen7 avatar Jul 29 '21 07:07 fjchen7

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

Randalix avatar Oct 17 '22 08:10 Randalix