Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow configure if kubectx and kubens will be autocompletable commands. #431

Open
danim55 opened this issue Nov 20, 2024 · 1 comment
Open

Comments

@danim55
Copy link

danim55 commented Nov 20, 2024

I have get used to write kub ku or kube and then press the tab to autocomplete for kubectl. With these new commands the autocompletion is not working.

I know, I can create an alias... I have already done that but the alias does not work with the autocompletion of the next parameters.

Example: If I want to write kubectl port-forward svc/some-service some port.

  • When writing k as an alias for kubectl if then I write port and try to autocomplete it does not work.
  • When writing kubectl and then port it autocompletes.

My point is that it will be cool to remove kubectx and kubens from the autocompletion. Maybe with an enviroment variable or some type of configuration when installing.

@danim55
Copy link
Author

danim55 commented Nov 20, 2024

As a temporal solution we could use this added to the vim ~/.bashrc

# Custom completion for kube
_kube_completion() {
    local cur=${COMP_WORDS[COMP_CWORD]}  # Current word being completed
    COMPREPLY=()  # Clear existing completions
    
    # Only suggest commands starting with "kubect"
    COMPREPLY=( $(compgen -W "kubectl kubectx kubens" -- "$cur" | grep ^kubectl) )
}

# Use complete with -I option
complete -o bashdefault -I -F _kube_completion kube

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant