2022-05-18 11:28:39 +03:00
|
|
|
#!/bin/zsh
|
|
|
|
|
2024-02-18 02:32:08 +03:00
|
|
|
typeset -A ZSHU_COMP_EXTERNAL
|
2022-05-18 11:28:39 +03:00
|
|
|
|
2024-02-18 02:32:08 +03:00
|
|
|
for i ( kubectl podman skopeo docker ) ; do
|
|
|
|
ZSHU_COMP_EXTERNAL[$i]="command $i completion zsh"
|
2022-07-19 02:41:45 +03:00
|
|
|
done ; unset i
|
2024-02-18 02:32:08 +03:00
|
|
|
# ZSHU_COMP_EXTERNAL[yq]='command yq shell-completion zsh'
|
|
|
|
## example of "automatic" shell completion generation
|
|
|
|
__z_comp_ext__yq() { command yq shell-completion zsh ; }
|
|
|
|
|
|
|
|
## example of more complex shell completion generation
|
|
|
|
# __z_comp__shifty_nifty() { command shifty-nifty completion zsh | sed -E 's/shifty_nifty/shifty-nifty/g' ; }
|
|
|
|
# ZSHU_COMP_EXTERNAL[shifty-nifty]='__z_comp__shifty_nifty'
|
|
|
|
|
|
|
|
z-comp-auto() {
|
|
|
|
local c f
|
|
|
|
|
|
|
|
for c ( ${(k)ZSHU_COMP_EXTERNAL} ) ; do
|
|
|
|
__z_comp_external "$c" "${(@s: :)ZSHU_COMP_EXTERNAL[$c]}" && unset "ZSHU_COMP_EXTERNAL[$c]"
|
|
|
|
done
|
|
|
|
|
|
|
|
for f ( ${functions[(I)__z_comp_ext__*]} ) ; do
|
|
|
|
c=${f#__z_comp_ext__}
|
|
|
|
__z_comp_external $c $f && unset -f "$f"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
z-comp-auto
|