sbstp / kubie

A more powerful alternative to kubectx and kubens
https://blog.sbstp.ca/introducing-kubie/
zlib License
2.01k stars 101 forks source link

Command prompt is broken when using zim on zshell #87

Closed c10l closed 11 months ago

c10l commented 3 years ago

I've recently migrated my zsh config to use zim. Unfortunately, this broke kubie because it expects to find certain files in known locations:

$ kubie ctx
/Users/c10l/.zshrc:source:102: no such file or directory: /var/folders/2l/z3r2cq7j3hd79c4091tq42hr0000gn/T/.tmpc9w8CC/.zim/zimfw.zsh
/Users/c10l/.zshrc:source:104: no such file or directory: /var/folders/2l/z3r2cq7j3hd79c4091tq42hr0000gn/T/.tmpc9w8CC/.zim/init.zsh
/Users/c10l/.zlogin:source:7: no such file or directory: /var/folders/2l/z3r2cq7j3hd79c4091tq42hr0000gn/T/.tmpc9w8CC/.zim/login_init.zsh
c10l@laptop ~ %

I managed to work around those errors by setting ZIM_HOME=/Users/c10l/.zim but then something else broke as it tries to find .zimrc under $HOME, which is overridden at that point to the kubie temp dir:

$ kubie ctx
_zimfw_source_zimrc:source:3: no such file or directory: /var/folders/2l/z3r2cq7j3hd79c4091tq42hr0000gn/T/.tmp7RzL0l/.zimrc
Failed to source /var/folders/2l/z3r2cq7j3hd79c4091tq42hr0000gn/T/.tmp7RzL0l/.zimrc
/Users/c10l/.zim/modules/ohmyzsh/plugins/kubectl/kubectl.plugin.zsh:5: read-only file system: /kubectl_completion

Suggestion: allow me to give a list of files and directories to copy to the temp dir when switching contexts. This way I can specify .zimrc and .zim/ which should make this work.

sebastianst commented 1 year ago

I can confirm that this is still an issue

$ kubie ctx
_zimfw_source_zimrc:source:3: no such file or directory: /tmp/.tmpyj7aAo/.zimrc
Failed to source /tmp/.tmpyj7aAo/.zimrc
_zimfw_source_zimrc:source:3: no such file or directory: /tmp/.tmpyj7aAo/.zimrc
Failed to source /tmp/.tmpyj7aAo/.zimrc
/home/seb/.zshrc:source:114: no such file or directory: /tmp/.tmpyj7aAo/.zim/init.zsh
/home/seb/.aliases:unalias:76: no such hash table element: gt
brianclin commented 1 year ago

kubie overrides the ZDOTDIR variable with the temp path and zim looks for .zimrc file in ${ZDOTDIR}/.zimrc when the variable is defined.

Zim Settings

Assuming your .zimrc file is in $HOME: you can add export ZIM_CONFIG_FILE=$HOME/.zimrc to your .zshrc

This should lead to no errors from kubie.

sebastianst commented 12 months ago

Thanks, this works!