kubie
kubie copied to clipboard
zsh: kubectl auto-complete does not work in the kubie sub shell
☸ kind-kind (default) in ~ took 2m47s
$ k get <TAB> # works
$ kubie ctx foo # new shell
$ k get <TAB> # does not work
$ zsh --version
zsh 5.8 (x86_64-apple-darwin20.1.0)
Any ideas?
Yeah, could be an issue with the custom init script we use https://github.com/sbstp/kubie/blob/master/src/shell/zsh.rs
I'm also having this issue in bash.
Me too. It works kind of strange. Part of auto completion works, part not. For example get pods,secrets,daemonset works. And get deploy, statefullset doesn't. Weird. Sometimes exit the shell completely helps, but then it return without reason.
So I think kubie
is mangling ZDOTDIR environment variable, which some ZSH plugins depend on to initialize correctly. For example, prezto is using this initialization code inside .zshrc
if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then
source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"
fi
Kubie should probably either restore or unset ZDOTDIR before loading users' .zshrc
:
# Backup Kubie's ZDOTDIR
kubie_ZDOTDIR=$ZDOTDIR
# Restore or unset users' ZDOTDIR
if (( ${+_KUBIE_USER_ZDOTDIR} )); then
export ZDOTDIR=$_KUBIE_USER_ZDOTDIR
else
unset ZDOTDIR
fi
# Load users' .zshrc with their ZDOTDIR
if [[ -f "${ZDOTDIR:-$HOME}/.zshrc" ]] ; then
source "${ZDOTDIR:-$HOME}/.zshrc"
fi
# Restore Kubie's ZDOTDIR
ZDOTDIR=$kubie_ZDOTDIR
Though perhaps a better way is to unset / restore the user's ZDOTDIR immediately at the start of the script.