Skip to content

Fuzzy completion for custom commands is broken. #1170

Closed
@gregorias

Description

  • 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

Steps to reproduce and behaviour

  1. Run complete -F _fzf_path_completion -o default -o bashdefault fake_cmd
  2. Type fake_cmd any_dir<TAB><TAB>

Now typing fake_cmd **<TAB><TAB> stops working and returns default tab completion.

Root cause

In step 2. the completion function for fake_cmd is changed to bash' default - _minimal.

Before step 2., complete | grep fake_cmd outputs complete -F _fzf_path_completion -o default -o bashdefault fake_cmd, but after step 2., the command outputs complete -F _minimal fake_cmd.

This change happens, when _completion_loader is run at:

_completion_loader "$@"

L125 affects all other commands, however the original completion function is restored later -

fzf/shell/completion.bash

Lines 127 to 128 in 9615c4e

eval "$(complete | command grep "\-F.* $orig_cmd$" | _fzf_orig_completion_filter)"
source "${BASH_SOURCE[0]}"

This restoration doesn't affect fake_cmd, because it is not in a_cmds:
a_cmds="

Note that this if the fake_cmd is inside /etc/bash_completion.d/, then _completion_loader doesn't fail, and the switch doesn't happen.

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions