fzf: cd tab completion not working
- Category
- fzf binary
- fzf-tmux script
- Key bindings
- Completion
- Vim
- Neovim
- Etc.
- OS
- Linux
- Mac OS X
- Windows
- Windows Subsystem for Linux
- Etc.
- Shell
- bash
- zsh
- fish
For some reason, cd <tab> is not auto-complete for me. I am running on a linux terminal X11-forwarded to a Windows machine.
fzf version is 0.16.6.
I have narrowed down the problem to these lines in shell/completion.bash:
# Directory
for cmd in $d_cmds; do
_fzf_defc "$cmd" _fzf_dir_completion "-o nospace -o plusdirs"
done
Commenting them out gives me back the regular tab autocompletion behavior.
Please let me know if there’s some way I could debug this further.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 5
- Comments: 43 (12 by maintainers)
OK running on Mac with homebrew and I discovered that for me, it has to go to the BOTTOM of ~/.bashrc. I think this is because there are some completions that are overwriting. A quick look at the bash.completion script makes it hard to figure out what is going on here, but basically the shortcuts seem to work anywhere, but the
**completion only works when it behind all the other completions. I have to have it after the bash completion installation.This probably related to me installing bash_completion and not bash_completion@2 as described by https://docs.brew.sh/Shell-Completion, but for v1 on bash 5.x this does work
And with the bash completion v2 it is the same thing, there line is somewhat different, but fzf has to come after it, you might want to add to the README
I had same issue on bash, and finally figured out (at least in my case) it’s related to the location fzf.bash get sourced, at the end of my default .bashrc, there are some stock completion like below erased fzf completion, after moving fzf bash source after this fix the issue.
.bashrc:
# source fzf.bash # was sourced here and not working
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then . /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
source fzf.bash # move to here works!
@richtong
That’s correct. The fzf completion should be loaded at the end. The completion script of fzf is smart enough to keep the previous completion function as the fallback, but you can’t expect the other scripts to do the same.
@rayiik Thanks for trying to help, but @richtong already found the right answer.