875e7c4077c08b6cf5547929d403f70a52836388
- Author
- (╯°□°)╯︵ uᴉǝssnH ɐɟɐʇsoW <mostafa.hussein91@gmail.com>
- Committer
- GitHub <noreply@github.com>
- Date
Message
feat(helm): cache completion file in the background (#8326)
Diff
1diff --git a/plugins/helm/helm.plugin.zsh b/plugins/helm/helm.plugin.zsh
2index 78499c15d7f8a73600453da9bfb62cb08ef4538c..472c1c9dde025d1263a6912d64c1a8980fceefd4 100644
3--- a/plugins/helm/helm.plugin.zsh
4+++ b/plugins/helm/helm.plugin.zsh
5@@ -1,7 +1,22 @@
6-# Autocompletion for helm.
7-#
8-# Copy from kubectl : https://github.com/pstadler
9+if (( ! $+commands[helm] )); then
10+ return
11+fi
12+
13+# TODO: 2021-12-28: delete this block
14+# Remove old generated file
15+command rm -f "${ZSH_CACHE_DIR}/helm_completion"
16
17-if [ $commands[helm] ]; then
18- source <(helm completion zsh)
19+# TODO: 2021-12-28: remove this bit of code as it exists in oh-my-zsh.sh
20+# Add completions folder in $ZSH_CACHE_DIR
21+command mkdir -p "$ZSH_CACHE_DIR/completions"
22+(( ${fpath[(Ie)"$ZSH_CACHE_DIR/completions"]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath)
23+
24+# If the completion file doesn't exist yet, we need to autoload it and
25+# bind it to `helm`. Otherwise, compinit will have already done that.
26+if [[ ! -f "$ZSH_CACHE_DIR/completions/_helm" ]]; then
27+ declare -A _comps
28+ autoload -Uz _helm
29+ _comps[helm]=_helm
30 fi
31+
32+helm completion zsh >| "$ZSH_CACHE_DIR/completions/_helm" &|