Skip to content

_fzf_complete_${cmd} runs after aliases are resolved #4603

@chancez

Description

@chancez

Checklist

  • I have read through the manual page (man fzf)
  • I have searched through the existing issues
  • For bug reports, I have checked if the bug is reproducible in the latest version of fzf

Output of fzf --version

0.66.1 (c1b259c)

OS

  • Linux
  • macOS
  • Windows
  • Etc.

Shell

  • bash
  • zsh
  • fish

Problem / Steps to reproduce

I'm trying to write some completion functions but running into issues when my completions involve aliases. For example, I'm trying to write a function _fzf_complete_kubectl() { ... } but I have alias kubectl=kubecolor. Additionally, if I echo the input, the actual args are the non-aliased value.

Eg:

_fzf_complete_kubecolor() {
  echo "args: $@"
}

kubectl get **<TAB> results in: kubectl get **args: kubectl get

Honestly, I'm not sure what I want, because while it would be great to define _fzf_complete_kubectl to work with alias kubectl=kubecolor, I also have alias k=kubectl which is how I normally call kubectl, so I both want aliases to be resolved, but I don't want aliases to be resolved, you see what I mean? Eg: I want to define _fzf_complete_kubectl and have it work with kubectl and k even though both are aliases to different things.

Currently I'm thinking I might just create a single function implementation and then dynamically define the _fzf_complete_${cmd} for each alias, but I'm open to suggestions.

Something like this is my current approach:

for cmd in kubectl k kubecolor; do
  _fzf_complete_${cmd}() {
    _helper_fzf_complete_kubectl "$@"
  }
done

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions