shell-completion/zsh: complete hidden images when word starts with "."

Show hidden images in the completion results, but only if the current
word starts with ".", such that
- `machinectl clone <Tab>` will only offer non-hidden images, but
- `machinectl clone .<Tab>` will offer both hidden and non-hidden images
This commit is contained in:
Ivan Shapovalov 2024-01-23 01:10:49 +01:00
parent 57d389c3fb
commit 9a887b1421

View file

@ -3,7 +3,12 @@
(( $+functions[__machinectl_get_images] )) ||
__machinectl_get_images () {
machinectl --no-legend list-images | {while read -r a b; do echo $a; done;}
local -a flags
if [[ $PREFIX == .* ]]; then flags=( --all ); fi
machinectl --no-legend list-images $flags | {while read -r a b; do
# escape : and \; do not interpret existing escape sequences
printf -- "%s\n" ${a//(#b)(\\|:)/\\$match}
done;}
}
(( $+functions[_machinectl_images] )) ||