]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
zsh: add systemd-id128 completions
authorRonan Pigott <ronan@rjp.ie>
Sun, 1 Mar 2026 16:47:16 +0000 (09:47 -0700)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 2 Mar 2026 06:25:33 +0000 (15:25 +0900)
shell-completion/zsh/_systemd-id128 [new file with mode: 0644]
shell-completion/zsh/meson.build

diff --git a/shell-completion/zsh/_systemd-id128 b/shell-completion/zsh/_systemd-id128
new file mode 100644 (file)
index 0000000..2cc06de
--- /dev/null
@@ -0,0 +1,55 @@
+#compdef systemd-id128
+
+local context state state_descr line
+typeset -A opt_args
+local expl
+
+local -a opt_common=(
+       {-h,--help}'[show a help message and exit]'
+       '--no-pager[do not pipe output into a pager]'
+       '--no-legend[do not show the headers and footers]'
+       '(-j)--json=[output inspection data in json format]:json-mode:(pretty short off)'
+       '(--json)-j[equivalent to --json=short or --json=pretty on TTY]'
+       '-p[generate samples of program code]'
+       '(-P --value)'{-P,--value}'[only print the value]'
+       '(-a --app-specific)'{-a+,--app-specific=}'[generate app-specific IDs]'
+       '(-u --uuid)'{-u,--uuid}'[output in uuid format]'
+)
+
+local -a id128_commands=(
+       'new:generate a new id'
+       'machine-id:print the id of the current machine'
+       'boot-id:print the id of the current boot'
+       'invocation-id:print the id of the current invocation'
+       'var-partition-uuid:print the uuid of the /var partition'
+       'show:print one or more uuids'
+)
+
+_systemd-id128_names() {
+       local expl
+       local -a names=( ${${(@f)"$(_call_program -l id128-name systemd-id128 show)"}%% *} )
+       _wanted id128-name expl "name" compadd "$@" -a - names
+}
+
+local ret=1
+_arguments -s "$opt_common[@]" \
+       ':command:->command' \
+       '*:: :->option-or-argument' && ret=0
+
+case $state in
+       command)
+               _describe -t command 'id128 command' id128_commands && ret=0
+               ;;
+       option-or-argument)
+               local curcontext=${curcontext%:*:*}:systemd-id128-$words[1]:
+               case $words[1] in
+                       *-id)
+                               _arguments -s "$opt_common[@]" && ret=0
+                               ;;
+                       show)
+                               _arguments -s "$opt_common[@]" ':name:_systemd-id128_names' && ret=0
+                               ;;
+               esac
+               ;;
+esac
+return ret
index bcd7899a15386e7f1bd894e856258f4d27fcd737..c5ee8d43a90d4e713b5885360bef95f9b5c56192 100644 (file)
@@ -36,6 +36,7 @@ foreach item : [
         ['_systemd',                  ''],
         ['_systemd-analyze',          ''],
         ['_systemd-delta',            ''],
+        ['_systemd-id128',            ''],
         ['_systemd-inhibit',          'ENABLE_LOGIND'],
         ['_systemd-nspawn',           ''],
         ['_systemd-path',             ''],