Given two commands:
command1
- which has completions already set up for itcommmand2
- which is a wrapper function, that in the end callscommand1 ARG
How do I make command2
complete in the same manner as command1 ARG1
would without writing a custom completion for command1
?
Here's an example:
alias command1="git ls-files"
command2() {
echo "I'm a wrapper for git ls-files" >&2
git ls-files $@
}
One can do compdef command2=command1
- but that will make command2
complete the same way as git
would and not like git ls-files
.
Edit: I'm looking for a broad and general solution that'd also work with commands that do not define separate completion functions such as git has. For these you can do what Marlon Richert suggested below.
Here's a better example:
alias command1="kubectl get pod"
command2() {
echo "I'm a wrapper for kubectl get pod" >&2
kubectl get pod $@
}