]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
bash-completion/creds: generate suggestions by systemd-creds itself 35579/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 12 Dec 2024 02:51:36 +0000 (11:51 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 12 Dec 2024 06:25:38 +0000 (15:25 +0900)
Follow-ups for 783f794e89996ae7f2ae1872d65c515a672437fa.

shell-completion/bash/systemd-creds

index 310106b936e0ed332f368733e272deaac088f0fe..c16619e94f0ca34dffc6166ada1a8f10da2d9f3a 100644 (file)
@@ -25,10 +25,9 @@ __contains_word() {
 }
 
 __get_tpm2_devices() {
-    local i
-    for i in /dev/tpmrm*; do
-        [ -c "$i" ] && printf '%s\n' "$i"
-    done
+    local a b c
+    systemd-creds --no-legend --quiet --tpm2-device=list 2>/dev/null | \
+        { while read -r a b c; do echo " $a"; done }
 }
 
 __get_creds() {
@@ -129,10 +128,10 @@ _systemd_creds() {
                 comps=$( systemd-creds --json=help 2>/dev/null )
                 ;;
             --transcode)
-                comps='base64 unbase64 hex unhex'
+                comps=$( systemd-creds --no-legend --transcode=help 2>/dev/null )
                 ;;
             --with-key)
-                comps='host tpm2 host+tpm2 null auto auto-initrd'
+                comps=$( systemd-creds --no-legend --with-key=help 2>/dev/null )
                 ;;
         esac
         COMPREPLY=( $(compgen -W '$comps' -- "$cur") )