From 9a887b14215a1be413e572493cb869d4359f9b22 Mon Sep 17 00:00:00 2001 From: Ivan Shapovalov Date: Tue, 23 Jan 2024 01:10:49 +0100 Subject: [PATCH] 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 ` will only offer non-hidden images, but - `machinectl clone .` will offer both hidden and non-hidden images --- shell-completion/zsh/_machinectl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/shell-completion/zsh/_machinectl b/shell-completion/zsh/_machinectl index 54afa95bf68..cb43721961e 100644 --- a/shell-completion/zsh/_machinectl +++ b/shell-completion/zsh/_machinectl @@ -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] )) || -- 2.47.3