kubectl-plugins icon indicating copy to clipboard operation
kubectl-plugins copied to clipboard

Make `kubectl-prompt` suitable for use with zsh

Open grzesuav opened this issue 5 years ago • 8 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)

grzesuav avatar Apr 10 '19 23:04 grzesuav

I created PR with POC for helper function

grzesuav avatar Apr 10 '19 23:04 grzesuav

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.

jordanwilson230 avatar Apr 11 '19 04:04 jordanwilson230

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 avatar May 07 '19 15:05 grzesuav

@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!

jordanwilson230 avatar May 10 '19 21:05 jordanwilson230

+1 to all of this.

ross-bryan avatar May 22 '19 12:05 ross-bryan

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

missedone avatar Jul 24 '20 06:07 missedone

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

jordanwilson230 avatar Aug 05 '20 12:08 jordanwilson230

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

mabushey avatar Mar 02 '21 23:03 mabushey