diff --git a/.config/zsh/completion/external.zsh b/.config/zsh/completion/external.zsh index 48e9821..1a70433 100644 --- a/.config/zsh/completion/external.zsh +++ b/.config/zsh/completion/external.zsh @@ -5,24 +5,13 @@ typeset -A ZSHU_COMP_EXTERNAL for i ( kubectl podman skopeo docker ) ; do ZSHU_COMP_EXTERNAL[$i]="command $i completion zsh" done ; unset i -# ZSHU_COMP_EXTERNAL[yq]='command yq shell-completion zsh' + ## example of "automatic" shell completion generation +# ZSHU_COMP_EXTERNAL[yq]='command yq shell-completion zsh' __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 diff --git a/.config/zsh/lib/completion.zsh b/.config/zsh/lib/completion.zsh index f1e3d3e..164d5e2 100644 --- a/.config/zsh/lib/completion.zsh +++ b/.config/zsh/lib/completion.zsh @@ -1,5 +1,7 @@ #!/bin/zsh +typeset -gA ZSHU_COMP_FORCE + ZSHU[f_compdump]="${ZSHU[d_cache]}/compdump" ZSHU[d_compcache]="${ZSHU[d_cache]}/compcache" [ -d "${ZSHU[d_compcache]}" ] || mkdir -p "${ZSHU[d_compcache]}" @@ -111,3 +113,21 @@ z-comp-invalidate() { [ -f "$f" ] || return 2 rm -f "$f" || return 3 } + +## reload or new session are required to regenerate completions +z-comp-flush() { + find "${ZSHU[d_cache]}/completion/" -xdev -type f '!' -name '.keep' -delete +} + +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 +} \ No newline at end of file diff --git a/.config/zsh/local.zsh.example b/.config/zsh/local.zsh.example index 66f2e34..77383d4 100644 --- a/.config/zsh/local.zsh.example +++ b/.config/zsh/local.zsh.example @@ -1,4 +1,10 @@ #!/bin/zsh -typeset -gA ZSHU_COMP_FORCE +## skip system-wide podman completion and produce own ZSHU_COMP_FORCE[podman]=1 + +## systemctl status podman.socket +export DOCKER_HOST=/run/podman/podman.sock + +## systemctl --user status podman.socket +export DOCKER_HOST=${XDG_RUNTIME_DIR}/podman/podman.sock