junegunn / junegunn/fzf

_fzf_complete_${cmd} runs after aliases are resolved

Open
#4,603 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
83k
Forks
2.9k
Avg merge
17h 8m
Merged PRs (30d)
10

Description

### Checklist

- [x] I have read through the manual page (`man fzf`)
- [x] 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 (c1b259c0)

### OS

- [ ] Linux
- [x] macOS
- [ ] Windows
- [ ] Etc.

### Shell

- [ ] bash
- [x] 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 **` 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
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the `_fzf_complete_${cmd}` behavior in zsh with the `kubectl`, `kubecolor`, and `k` aliases shown in the report. First clarify whether dispatch should use the typed alias or the resolved command; done means the agreed completion function is invoked consistently for the supported aliases.

Written by the indexing model from the issue text.

Assessment

Tech stack
shell, zsh
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.