jordanwilson230 / kubectl-plugins

A Collection of Plugins for kubectl Integration (exec as any user, context switching, etc).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make `kubectl-prompt` suitable for use with zsh

grzesuav opened this issue · comments

Is your feature request related to a problem? Please describe.
Currently it is impossible to use kubectl-prompt with zsh because :

  • function definition does not work in zsh
  • changes are kept in .bash_profile

Describe the solution you'd like

  • change function kubectl () definition to be both bash and zsh compatibile
  • store configuration (cluster, namespaces, function definition) outside .bash_profile
  • source configuration (from above) in .bash_profile or .zshrc (depending on shell)

Additional context
Currently when I extracted configuration to separate file and try to source it in zsh I get

kubectl: command not found: kubectl () {\n\tkube=$(which kubectl) \n\t$kube prompt "${@}" && command $kube "${@}"\n}

probably because different handling of references in zsh (problematic part : kube=$(which kubectl) inside a function called kubectl)

I created PR with POC for helper function

Thanks @grzesuav, those are some good points. Support for zsh is a reasonable request, and I appreciate the starter PR as well. I will take a look at this when I have time -- hopefully by tomorrow we can have something.

hi @jordanwilson230 , if sth like this is ok with you I can dig it further :

  • detection of current shell
  • usage of external file (which can be sourced in basrc or zshrc)

Any thoughts from your side ?

@grzesuav That would be terrific and appreciated. I apologize its taken so long, I've been bogged down in work. I'd love to see what you're able to come up with. Thanks!

+1 to all of this.

looking for support zsh as well, this is a so cool plugin may save my life in future, never mess up prod env.

Yeah, if anyone wants to contribute to make this happen, that'd be sweet.

Just copy the plugins to /usr/local/bin and it works. No reason to do all this song and dance pollute the PATH crap.