-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
Hi! First off all, thanks for this wonderful script.
I'm currently in the process of migrating from oh-my-zsh to a setup with no plugin managers and I'm trying to learn how to setup my stuff, but I'm too stupid to make your script work with my custom bash completions.
With oh-my-zsh I would put my completion scripts into a folder that's included in my fpath and then autoload them into my .zshrc. For example for the binary kns
it would look like this:
autoload -Uz _kns
autoload -U +X bashcompinit && bashcompinit
complete -F _kns kns
With zsh-bash-completions-fallback
installed I thought I simply have to put the completion script into /usr/share/bash-completion/completions
and be done but I think I'm missing something.
The script in question if it's needed (/usr/share/bash-completion/completions/_kns
):
_kns() {
if ! kubectl config current-context > /dev/null 2>&1 ; then
return
fi
local cur="${COMP_WORDS[COMP_CWORD]}"
if [[ ${cur} == -* || ${COMP_CWORD} -ne 1 ]]; then
return
fi
local IFS=$'\n'
local suggestions=$(kubectl get ns -o custom-columns=NAME:.metadata.name --no-headers)
COMPREPLY=($(compgen -W "$suggestions" -- ${cur}))
}
complete -F _kns kns
Metadata
Metadata
Assignees
Labels
No labels