From d441345096b4042b6c158f3d94062ef89d424ddb Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 25 Jul 2021 11:43:24 +0200 Subject: Adding sensible default lookups for container key bash-completion. Signed-off-by: Daniel Baumann --- share/bash-completion/container | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'share/bash-completion/container') diff --git a/share/bash-completion/container b/share/bash-completion/container index 44a48e7..bb3eb41 100644 --- a/share/bash-completion/container +++ b/share/bash-completion/container @@ -136,9 +136,25 @@ _container() ;; key) - opts="-a --add -l --list -r --remove" - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) - return 0 + case "${prev}" in + -a|--add) + opts="$(cd /usr/share/compute-tools/keys 2>/dev/null && ls *.pub 2>/dev/null | sed -e 's|.*/||g' -e 's|.pub$||g')" + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + return 0 + ;; + + -r|--remove) + opts="$(gpg --homedir /etc/compute-tools/keys --list-keys | grep ^uid | sed -e 's|.*<||' -e 's|>||')" + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + return 0 + ;; + + *) + opts="-a --add -r --remove -l --list" + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + return 0 + ;; + esac ;; limit) -- cgit v1.2.3